Telebot Telegram Bot Active when Run it with Powershell inactive with Heroku
Tags: python, telebot, telegram, bot
Published: 2022-03-29 16:20:54

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)
`