krakotay
MModular
•Created by krakotay on 9/9/2023 in #questions
Hi all. I'm trying to create telegram bot with mojo (just for fan), but get an Error
That's my code
~~^~~~~~~~~
telegram bot.mojo:1:1: note: function declared here
from python import Python
^
telegram bot.mojo:6:6: error: cannot use a dynamic value in decorator
@bot.message_handler(commands=['start', 'help'])
^~~
telegram bot.mojo:10:31: error: unexpected token in expression
@bot.message_handler(func=lambda message: True)
from python import Python
def main():
let telebot = Python.import_module("telebot")
let bot = telebot.TeleBot('TOKEN')
@bot.message_handler(commands=['start', 'help'])
def send_welcome(message):
bot.reply_to(message, "Howdy, how can I help you?")
@bot.message_handler(func=lambda message: True)
def echo_all(message):
bot.reply_to(message, message.text)
bot.polling()
krakotay@krakotay:~/Documents/mojo$ mojo build telegram\ bot.mojo
telegram bot.mojo:8:21: error: invalid call to 'call': argument #1 cannot be converted from 'object' to 'PythonObject'
bot.reply_to(message, "Howdy, how can I help you?")
2 replies