simulation.telegram package¶
Submodules¶
simulation.telegram.balog_bot module¶
BalogBot class¶
https://www.codementor.io/garethdwyer/building-a-telegram-bot-using-python-part-1-goi5fncay
Author: Shuo Zhang
-
class
simulation.telegram.balog_bot.BalogBot¶ Bases:
objectTelegram channel
-
static
build_keyboard(items)¶ Parameters: items – input items Returns: reply markup
-
get_json_from_url(url)¶ Gets the string response and parses it into a Python dictionary
Parameters: url – url Returns: response in json
-
static
get_last_chat_id_and_text(updates)¶ Parameters: updates – updates Returns: (text, chat id)
-
static
get_last_update_id(updates)¶ Parameters: updates – updates Returns: last chat id
-
get_updates(offset=None)¶ Calls the API and retrieves a list of updates
Parameters: offset – offset Returns: recent updates in a list
-
static
get_url(url)¶ Downloads the content from a URL and returns a string.
Parameters: url – url Returns: a string
-
handle_updates(updates)¶ Handle the updates
Parameters: updates – updates
-
send_message(text, chat_id, reply_markup=None)¶ Parameters: - text – text
- chat_id – chat id
- reply_markup – reply markup
-
static
-
simulation.telegram.balog_bot.main()¶
simulation.telegram.dbhelper module¶
DBHelper¶
- Optional dbhelper for recording dialogues.
-
class
simulation.telegram.dbhelper.DBHelper(dbname='todo.sqlite')¶ Bases:
objectDB helper
-
add_item(item_text, owner)¶ Add item to db.
Parameters: - item_text – next item
- owner – owner
-
delete_item(item_text, owner)¶ Delete item from db.
Parameters: - item_text – next item
- owner – owner
-
get_items(owner)¶ Get recent updates for the current user.
Parameters: owner – owener Returns: updates
-
setup()¶ Set up the channel.
Returns:
-
Module contents¶
We use telegram to collect human-machine dialogues.