mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
No asyncio.run()
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from telebot.async_telebot import AsyncTeleBot
|
||||
import asyncio
|
||||
|
||||
import telebot
|
||||
bot = AsyncTeleBot('TOKEN')
|
||||
|
||||
@@ -8,4 +8,4 @@ async def make_some(message: telebot.types.ChatJoinRequest):
|
||||
await bot.send_message(message.chat.id, 'I accepted a new user!')
|
||||
await bot.approve_chat_join_request(message.chat.id, message.from_user.id)
|
||||
|
||||
asyncio.run(bot.polling(skip_pending=True))
|
||||
bot.polling(skip_pending=True)
|
||||
@@ -1,6 +1,6 @@
|
||||
from telebot import types,util
|
||||
from telebot.async_telebot import AsyncTeleBot
|
||||
import asyncio
|
||||
|
||||
bot = AsyncTeleBot('TOKEN')
|
||||
|
||||
#chat_member_handler. When status changes, telegram gives update. check status from old_chat_member and new_chat_member.
|
||||
@@ -30,4 +30,4 @@ async def my_chat_m(message: types.ChatMemberUpdated):
|
||||
@bot.message_handler(content_types=util.content_type_service)
|
||||
async def delall(message: types.Message):
|
||||
await bot.delete_message(message.chat.id,message.message_id)
|
||||
asyncio.run(bot.polling())
|
||||
bot.polling()
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import asyncio
|
||||
from telebot.async_telebot import AsyncTeleBot
|
||||
from telebot import asyncio_filters
|
||||
bot = AsyncTeleBot('TOKEN')
|
||||
@@ -10,4 +9,4 @@ async def answer_for_admin(message):
|
||||
|
||||
# Register filter
|
||||
bot.add_custom_filter(asyncio_filters.IsAdminFilter(bot))
|
||||
asyncio.run(bot.polling())
|
||||
bot.polling()
|
||||
|
||||
@@ -40,5 +40,4 @@ async def bye_user(message):
|
||||
bot.add_custom_filter(MainFilter())
|
||||
bot.add_custom_filter(IsAdmin())
|
||||
|
||||
import asyncio
|
||||
asyncio.run(bot.polling())
|
||||
bot.polling()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from telebot.async_telebot import AsyncTeleBot
|
||||
import telebot
|
||||
import asyncio
|
||||
bot = AsyncTeleBot('TOKEN')
|
||||
|
||||
|
||||
@@ -15,5 +14,4 @@ async def not_admin(message):
|
||||
|
||||
# Do not forget to register
|
||||
bot.add_custom_filter(telebot.asyncio_filters.ChatFilter())
|
||||
|
||||
asyncio.run(bot.polling())
|
||||
bot.polling()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from telebot.async_telebot import AsyncTeleBot
|
||||
import telebot
|
||||
import asyncio
|
||||
|
||||
bot = AsyncTeleBot('TOKEN')
|
||||
|
||||
|
||||
@@ -19,4 +19,4 @@ async def text_filter(message):
|
||||
bot.add_custom_filter(telebot.asyncio_filters.IsReplyFilter())
|
||||
bot.add_custom_filter(telebot.asyncio_filters.ForwardFilter())
|
||||
|
||||
asyncio.run(bot.polling())
|
||||
bot.polling()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from telebot.async_telebot import AsyncTeleBot
|
||||
import telebot
|
||||
import asyncio
|
||||
bot = AsyncTeleBot('TOKEN')
|
||||
|
||||
|
||||
@@ -18,4 +17,4 @@ async def text_filter(message):
|
||||
bot.add_custom_filter(telebot.asyncio_filters.TextMatchFilter())
|
||||
bot.add_custom_filter(telebot.asyncio_filters.TextStartsFilter())
|
||||
|
||||
asyncio.run(bot.polling())
|
||||
bot.polling()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import telebot
|
||||
from telebot import asyncio_filters
|
||||
from telebot.async_telebot import AsyncTeleBot
|
||||
import asyncio
|
||||
bot = AsyncTeleBot('TOKEN')
|
||||
|
||||
|
||||
@@ -72,4 +71,4 @@ bot.add_custom_filter(asyncio_filters.IsDigitFilter())
|
||||
# set saving states into file.
|
||||
bot.enable_saving_states() # you can delete this if you do not need to save states
|
||||
|
||||
asyncio.run(bot.polling())
|
||||
bot.polling()
|
||||
@@ -4,7 +4,6 @@
|
||||
# It echoes any incoming text messages.
|
||||
|
||||
from telebot.async_telebot import AsyncTeleBot
|
||||
import asyncio
|
||||
bot = AsyncTeleBot('TOKEN')
|
||||
|
||||
|
||||
@@ -24,4 +23,4 @@ async def echo_message(message):
|
||||
await bot.reply_to(message, message.text)
|
||||
|
||||
|
||||
asyncio.run(bot.polling())
|
||||
bot.polling()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from telebot.async_telebot import AsyncTeleBot
|
||||
import asyncio
|
||||
bot = AsyncTeleBot('TOKEN')
|
||||
|
||||
async def start_executor(message):
|
||||
@@ -16,4 +15,4 @@ bot.register_message_handler(start_executor, commands=['start']) # Start command
|
||||
# bot.register_edited_message_handler(*args, **kwargs)
|
||||
# And other functions..
|
||||
|
||||
asyncio.run(bot.polling(skip_pending=True))
|
||||
bot.polling(skip_pending=True)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from telebot.async_telebot import AsyncTeleBot
|
||||
import asyncio
|
||||
|
||||
bot = AsyncTeleBot('TOKEN')
|
||||
|
||||
@bot.message_handler(commands=['start', 'help'])
|
||||
@@ -10,4 +10,4 @@ async def send_welcome(message):
|
||||
async def echo_all(message):
|
||||
await bot.reply_to(message, message.text)
|
||||
|
||||
asyncio.run(bot.polling(skip_pending=True))# Skip pending skips old updates
|
||||
bot.polling(skip_pending=True)# Skip pending skips old updates
|
||||
|
||||
Reference in New Issue
Block a user