Skip to content

robinvd/telegram-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

telegram-bot

Haskell library/app for easy interacting with telegram

how to use!

message the bot with:

/tr <courseCode> <groups> where courseCode is the string after CourseCodes= until & on rooster.rug.nl and groups is a ',' seperated list of groups. They appear in the remarks section of the same page. Classes without a remark are always selected

now you can message the bot with /t or /timetable and get your timetable

install

git clone https://github.com/robinvd/telegram-bot

optional: edit the Main.hs with your token/extra extensions

stack build
stack exec telegram-exe

the default Main.hs expects your token as argument so: stack exec telegram-exe <token>

default modules

  • help: responds with a hardcoded message

  • timetable: fetches the timetable from the rug website, filters today, filters selected groups and responds with that info

Configuring

to start the bot call the function:

telegram :: TelegramSettings -> IO()

from the module Telegram. Possible settings are: token, updateDelay, actions, defaultMsg

making extensions:

type signature for extension should be extension-name :: Action Action is defined as:

type Action = ((Int, [T.Text]) -> IO SendMessageRequest)

as example you can take the help extension:

helpInfo :: Action
helpInfo (chatId, _) = return $ sendMessageRequest (T.pack $ show chatId) msg
  where msg = "Simple bot made by Robin to show timetables from the rug. available commands: /help, /timetable"

The second arguments is a list of arguments recieved, here it is ignored as the message is hardcoded

So "/newfunction arg1 arg2" will be parsed as ["/newfunction", "arg1", arg2"]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors