heig.user

Copyright 2019,2020 Gabriel Roch

This file is part of heig-bot.

heig-bot is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

heig-bot is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with heig-bot. If not, see <https://www.gnu.org/licenses/>.

class heig.user.User(user_id)[source]

User manager

Variables:
  • _user_id – Telegram id of user
  • _filename (str) – Filename of pickle file for user’s data stockage
  • _data (dict) – User’s data _data[“gaps”] see Gaps._data
__dict__ = mappingproxy({'__module__': 'heig.user', '__doc__': '\n User manager\n\n :ivar _user_id: Telegram id of user\n :vartype _user_id: \n\n :ivar _filename: Filename of pickle file for user\'s data stockage\n :vartype _filename: str\n\n :ivar _data: User\'s data\n _data["gaps"] see Gaps._data\n :vartype _data: dict\n ', '__init__': <function User.__init__>, 'id': <function User.id>, 'save': <function User.save>, 'destroy_data': <function User.destroy_data>, 'gaps': <function User.gaps>, 'is_admin': <function User.is_admin>, 'send_message': <function User.send_message>, 'debug': <function User.debug>, '__dict__': <attribute '__dict__' of 'User' objects>, '__weakref__': <attribute '__weakref__' of 'User' objects>})
__init__(user_id)[source]

Initialize User object, and if possible load user’s data

Parameters:user_id – Telegram userid
__module__ = 'heig.user'
__weakref__

list of weak references to the object (if defined)

debug(text)[source]

Display debug information on console

Parameters:text (str) – Information to display
destroy_data() → None[source]

Destroy all information about the user

Returns:None
gaps()[source]

Get gaps object for current user

Returns:Gaps object of current user
Return type:Gaps
id()[source]

get telegram id of user

is_admin()[source]

Indicate if this user is admin

Return type:bool
save()[source]

Save user’s data on disk

send_message(message, prefix='', suffix='', reply_to=0, context=None, chat_id=0, parse_mode=None)[source]

Send a message to user

Parameters:
  • message (str) – message to send
  • prefix (str) – prefix to add on all message
  • suffix (str) – suffix to add on all message
  • reply_to (int) – message id to reply
  • context (telegram.ext.CallbackContext) – context of message
  • chat_id (int) – chat id of destination of message
  • parse_mode (str) – Format of message (Markdown or HTML)