DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

NasserCzar
NasserCzar

Posted on

Telebot Telegram Bot Active when Run it with Powershell inactive with Heroku

Hello all ,

-- Breif --
So i create this bot for Java channel
his only function is show you index and the member of group choose a number of subject he interest and the bot bring a link of that subject.

-- The issue --
i run a test with the bot on powershell and works perfect.
when i deploy it on Heroku it doesn't work .

`import telebot
import time
// DEV BY SENSEI NASSER

bot_token = 'PUT YOUR TOKEN HERE'

bot = telebot.TeleBot(token=bot_token)

@bot.message_handler(commands=['start']) # welcome message handler
def send_welcome(message):
bot.reply_to(message, '(Welcome!)')

@bot.message_handler(commands=['help']) # welcome message handler
def send_welcome(message):
bot.reply_to(message, Helper)

Helper="""
ู…ุฑุญุจุง ุŒ ุฃู†ุง ุจูˆุช ู…ุณุงุนุฏ ู„ู‚ู†ุงุฉ ุงู„ุฌุงูุง ุŒ ู„ุฃุฎุชูŠุงุฑ ุงู„ู…ูˆุงุถูŠุน ูŠุฑุฌู‰ ูƒุชุงุจุฉ
/index
ู„ุนุฑุถ ูู‡ุฑุณ ุงู„ู…ูˆุงุถูŠุน ูˆู…ู† ุซู… ุฅุฎุชูŠุงุฑ ุฑู‚ู… ุงู„ู…ูˆุถูˆุน ูŠุณุจู‚ู‡ ุจุนู„ุงู…ุฉ #
"""

@bot.message_handler(commands=['index'])
def send_index(message):
bot.reply_to(message, text)

text="""
ุงู„ุฃูˆุงู…ุฑ : # ุซู… ุฃุฎุชุฑ ุงู„ุฑู‚ู… ู…ู† ุงู„ู‚ุงุฆู…ุฉ

1 = Java tutorial for beginners โ˜•
2 = variables โŒ

3 = swap two variables ๐Ÿ’ฑ
4 = user input โŒจ๏ธ
5 = expressions ๐Ÿงฎ
6 = GUI intro ๐Ÿšฉ

7 = Math class ๐Ÿ“

8 = random numbers ๐ŸŽฒ
9 = if statements ๐Ÿšง
10 = switches โฌ‡
11 = logical operators โ—
12 = while loop ๐Ÿ”„
13 = for loop โžฐ
14 = nested loops โžฟ
15 = arrays ๐Ÿš—
16 = 2D arrays ๐Ÿšš
17 = String methods ๐Ÿ’ฌ
18 = wrapper classes ๐ŸŽ
19 = ArrayList ๐Ÿงพ
20 = 2D ArrayList ๐Ÿ“œ
21 = for-each loop ๐Ÿ”ƒ
22 = methods ๐Ÿ“ž
23 = overloaded methods โ˜Ž๏ธ
24 = printf ๐Ÿ–จ๏ธ
25 = final keyword โ›”
26 = objects (OOP) โ˜•
27 = constructors ๐Ÿ‘ท
28 = variable scope ๐ŸŒ
29 = overloaded constructors ๐Ÿ•
30 = toString method ๐ŸŽ‰
31 = array of objects ๐Ÿฑ
32 = object passing ๐Ÿฌ
33 = static keyword โšก
34 = inheritance ๐Ÿ‘ช
35 = method overriding ๐Ÿ™…โ€โ™‚๏ธ
36 = super keyword ๐Ÿฆธโ€โ™‚๏ธ
37 = abstraction ๐Ÿ‘ป
38 = access modifiers ๐Ÿ”’
39 = encapsulation ๐Ÿ’Š
40 = copy objects ๐Ÿ–จ๏ธ
41 = interface ๐Ÿฆ…
42 = polymorphism ๐Ÿ
43 = dynamic polymorphism โœจ
44 = exception handling โš ๏ธ
45 = File class ๐Ÿ“
46 = FileWriter (write to a file) ๐Ÿ“
47 = FileReader (read a file) ๐Ÿ“–
48 = audio ๐Ÿ”Š
49 = GUI ๐Ÿ–ผ๏ธ
50 = labels ๐Ÿ‘จโ€๐Ÿ’ป
51 = panels ๐ŸŸฅ
52 = buttons ๐Ÿ›Ž๏ธ
53 = BorderLayout ๐Ÿงญ
54 = FlowLayout ๐ŸŒŠ
55 = GridLayout ๐Ÿ”ณ
56 = LayeredPane ๐Ÿ“š
57 = open a new GUI window ๐Ÿ—”
58 = JOptionPane ๐Ÿ›‘
59 = textfield ๐Ÿ“›
60 = checkbox โœ”๏ธ
61 = radio buttons ๐Ÿ”˜
62 = combobox ๐Ÿ“‘
63 = slider ๐ŸŒก๏ธ
64 = progress bar ๐Ÿ“Š
65 = menubar ๐Ÿ—„๏ธ
66 = select a file ๐Ÿ”Ž
67 = color chooser ๐ŸŽจ
68 = KeyListener ๐Ÿš€
69 = MouseListener ๐Ÿ–ฑ๏ธ
70 = drag and drop ๐Ÿ‘ˆ
71 = key bindings โŒจ๏ธ
72 = 2D graphics ๐Ÿ–๏ธ
73 = 2D animation ๐Ÿ‘พ
74 = generics โ“
75 = serialization ๐Ÿฅฃ
76 = TimerTask โŒš
77 = threads ๐Ÿงต
78 = multithreading ๐Ÿงถ
79 = packages ๐Ÿ“ฆ
80 = compile/run command prompt ๐Ÿ’ฝ
81 = executable (.jar) โ˜•
"""

index_list={
"1":"https://www.youtube.com/watch?v=NBIUbTddde4&list=PLZPZq0r_RZOMhCAyywfnYLlrjiVOkdAI1",
"2":"https://www.youtube.com/watch?v=so1iUWaLmKA",
"3":"https://www.youtube.com/watch?v=G0mFJUFMzjs",
"4":"https://www.youtube.com/watch?v=wAEPokhj5Q4",
"5":"https://www.youtube.com/watch?v=pZHJU9T0vwE",
"6":"https://www.youtube.com/watch?v=rWCnZKF-U3Q",
"7":"https://www.youtube.com/watch?v=w0VTlSOXBs8",
"8":"https://www.youtube.com/watch?v=VMZLPl16P5c",
"9":"https://www.youtube.com/watch?v=MY03bt_0JQI",
"10":"https://www.youtube.com/watch?v=Om3qzMoaIUo",
"11":"https://www.youtube.com/watch?v=919IUhotDCo",
"12":"https://www.youtube.com/watch?v=t6gmQaTMTtM",
"13":"https://www.youtube.com/watch?v=Rn16ugyorX0",
"14":"https://www.youtube.com/watch?v=oF3nBQFfpeM",
"15":"https://www.youtube.com/watch?v=ei_4Nt7XWOw",
"16":"https://www.youtube.com/watch?v=alwukGslBG8",
"17":"https://www.youtube.com/watch?v=P9hEmbfdiuc",
"18":"https://www.youtube.com/watch?v=4MiEznM8y8Q",
"19":"https://www.youtube.com/watch?v=1nRj4ALuw7A",
"20":"https://www.youtube.com/watch?v=9tBxJoQF74E",
"21":"https://www.youtube.com/watch?v=_IT8F5W0ZO4",
"22":"https://www.youtube.com/watch?v=v5p_SUfi710",
"23":"https://www.youtube.com/watch?v=kArGE1-vRrw",
"24":"https://www.youtube.com/watch?v=c2B_Av3x65s",
"25":"https://www.youtube.com/watch?v=DezKSLQ0-ls",
"26":"https://www.youtube.com/watch?v=kd3dr39rgrk",
"27":"https://www.youtube.com/watch?v=lhf8gaUx4yU",
"28":"https://www.youtube.com/watch?v=pSokndJB3Pw",
"29":"https://www.youtube.com/watch?v=Xngu-8pt_TA",
"30":"https://www.youtube.com/watch?v=GvbdMwfjB98",
"31":"https://www.youtube.com/watch?v=nhIB2S6NiFA",
"32":"https://www.youtube.com/watch?v=nRJWltqX4UY",
"33":"https://www.youtube.com/watch?v=wa1HzkMqY9A",
"34":"https://www.youtube.com/watch?v=Zs342ePFvRI",
"35":"https://www.youtube.com/watch?v=E-0MMeNi5Cw",
"36":"https://www.youtube.com/watch?v=oKZnHNM9Ew4",
"37":"https://www.youtube.com/watch?v=Lvnb83qt57g",
"38":"https://www.youtube.com/watch?v=T632kAJ_9VA",
"39":"https://www.youtube.com/watch?v=eboNNUADeIc",
"40":"https://www.youtube.com/watch?v=ljGH04_ASG4",
"41":"https://www.youtube.com/watch?v=GhslBwrRsnw",
"42":"https://www.youtube.com/watch?v=2hkngtWLGvE",
"43":"https://www.youtube.com/watch?v=tAIaK5LNatE",
"44":"https://www.youtube.com/watch?v=adTDlH0lhaA",
"45":"https://www.youtube.com/watch?v=MwYRVKfb2M0",
"46":"https://www.youtube.com/watch?v=kjzmaJPoaNc",
"47":"https://www.youtube.com/watch?v=Hr8tLlj32BQ",
"48":"https://www.youtube.com/watch?v=SyZQVJiARTQ",
"49":"https://www.youtube.com/watch?v=7GaAW-DdPuI",
"50":"https://www.youtube.com/watch?v=FR2UptJyaSM",
"51":"https://www.youtube.com/watch?v=dvzAuq-YDpM",
"52":"https://www.youtube.com/watch?v=-IMys4PCkIA",
"53":"https://www.youtube.com/watch?v=PD6pd6AMoOI",
"54":"https://www.youtube.com/watch?v=pDqjHozkMBs",
"55":"https://www.youtube.com/watch?v=ohNqQagkDDY",
"56":"https://www.youtube.com/watch?v=CmK1nObLxiw",
"57":"https://www.youtube.com/watch?v=HgkBvwgciB4",
"58":"https://www.youtube.com/watch?v=BuW7y21FcYI",
"59":"https://www.youtube.com/watch?v=dyDDUndlMnU",
"60":"https://www.youtube.com/watch?v=GwxvLzQoMYM",
"61":"https://www.youtube.com/watch?v=bn2KdCLqHlg",
"62":"https://www.youtube.com/watch?v=EAxV_eoYrIg",
"63":"https://www.youtube.com/watch?v=-rJdMaSgt38",
"64":"https://www.youtube.com/watch?v=JEI-fcfnFkc",
"65":"https://www.youtube.com/watch?v=7nEal9SJ6oI",
"66":"https://www.youtube.com/watch?v=A6sA9KItwpY",
"67":"https://www.youtube.com/watch?v=zEw8xObSWNA",
"68":"https://www.youtube.com/watch?v=BJ7fr9XwS2o",
"69":"https://www.youtube.com/watch?v=jptf1Wd_omw",
"70":"https://www.youtube.com/watch?v=_fsee3Nu15U",
"71":"https://www.youtube.com/watch?v=IyfB0u9g2x0",
"72":"https://www.youtube.com/watch?v=KcEvHq8Pqs0",
"73":"https://www.youtube.com/watch?v=tHNWIWxRDDA",
"74":"https://www.youtube.com/watch?v=rmk0LKv7sSY",
"75":"https://www.youtube.com/watch?v=TCMhP8trGwY",
"76":"https://www.youtube.com/watch?v=0dR-YAFFg6I",
"77":"https://www.youtube.com/watch?v=5qPaV3dLZKc",
"78":"https://www.youtube.com/watch?v=XhH93_woZIY",
"79":"https://www.youtube.com/watch?v=u_BZlRodfVU",
"80":"https://www.youtube.com/watch?v=paKrmEMvkU4",
"81":"https://www.youtube.com/watch?v=n2Dpffp_HLc"
}
key=list(index_list.keys())

@bot.message_handler(content_types=["text"])
def grap_link(message):
try:
k=message.text.split("#")
c=k[1].upper()
print(c)
if c in key:
bot.reply_to(message,
text=index_list[c])
except IndexError:
pass

bot.polling(none_stop=True)
`

Top comments (1)

Collapse
 
nasserczar profile image
NasserCzar

The files on Github is This :
Procfile inside it : worker: python main.py
requirements.txt inside it : PyTelegramBotAPI
and the main.py inside it the source code

We are hiring! Do you want to be our Senior Platform Engineer? Are you capable of chipping in across sysadmin, ops, and site reliability work, while supporting the open source stack that runs DEV and other communities?

This role might just be for you!

Apply now