Octeon¶
Octeon is modular telegram bot.
Eh, I dont know what else can I say about it.
Examples¶
Handling commands¶
import octeon
PLUGINVERSION = 2
plugin = octeon.Plugin()
@plugin.command(command="/hi",
description="Says 'Hi, %username%'",
inline_supported=True,
hidden=False)
def hi(bot, update, user, args):
return octeon.message(text="Hi, @%s" % user.username)
Ok, now lets tear down this thing:
import octeon
- imports various stuff which you would needPLUGINVERSION = 2
- version of plugin format. Current one is 2plugin = octeon.Plugin()
- create plugin instance. Make sure you named itplugin
, otherwise modloader will fail to load this plugin!@plugin.command
- this is decorator which used for command. Lets look what inside this thing!command="/hi"
- Command which will trigger functiondescription="Says 'Hi, %username%'"
- Description of function. This will appear in /help commandinline_supported=True
- Support for inline modehidden=False
- if True, this command wont appear in/help
def hi(bot, update, user, args):
- defining function. Arguments:return octeon.message(text="Hi, @%s" % user.username)
- sends a message!
Handling messages¶
Echo example:
import octeon
PLUGINVERSION = 2
plugin = octeon.Plugin()
@plugin.message(regex=".*")
def echo(bot, update):
return octeon.message(text=update.message.text)
import octeon
- imports various stuff which you would needPLUGINVERSION = 2
- version of plugin format. Current one is 2plugin = octeon.Plugin()
- create plugin instance. Make sure you named itplugin
, otherwise modloader will fail to load this plugin!@plugin.message
- this is decorator which used for command. Lets look what inside this thing!regex=".*"
- if following regex will match in any new message, Octeon will call this function. Regex in example matches every message
Other stuff you should know¶
octeon.message¶
Arguments:
text=""
- Text to send(or caption in case if file or photo is notNone
)photo=None
- Photo to send. Use a file-like object or pass a URL stringfile=None
- File to send. Use a file-like object or pass a URL stringinline_keyboard=None
- Inline Keyboard to send with message. See InlineKeyboardMarkupparse_mode=None
- Parse mode for text. See Formatting Optionsfailed=False
- If some process failed(like if there is no results for some search query), make it True and Octeon will add Inline Keyboard with “Delete message” button