Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
pip install shitgram==0.1.dev5
from shitgram import Bot, types
API_TOKEN = "API_TOKEN_HERE"
bot = Bot(API_TOKEN)
@bot.onUpdate
async def on_updates(bot: Bot, update: types.Update):
print(update)
@bot.onMessage()
async def on_message(bot: Bot, message: types.Message):
print(message)
@bot.onEditedMessage()
async def on_edited_message(bot: Bot, message: types.Message):
print(message)
# Custom filter
def filter_admin(message: types.Message):
admins = [123456789, 987654321]
return bool(message.from_user.id in admins)
@bot.onMessage(func=filter_admin)
@bot.onEditedMessage(func=filter_admin)
async def on_custom_filter(bot: Bot, message: types.Message):
print(message)
# Echo Bot
@bot.onMessage(func=lambda m: m.text)
async def echo(bot: Bot, message: types.Message):
return await bot.sendMessage(
message.chat.id,
message.text,
entities=message.entities
)
@bot.onCallbackQuery()
async def on_callback_query(bot: Bot, callback_query: types.CallbackQuery):
return await bot.sendMessage(
callback_query.message.chat.id,
callback_query.data
)
@bot.onInlineQuery()
async def on_inline_query(bot: Bot, inline_query: types.InlineQuery):
print(inline_query)
import asyncio
import logging
logging.basicConfig(level=logging.INFO)
asyncio.run(bot.start_polling())
# add allowed updates:
asyncio.run(bot.start_polling(allowed_updates=["message"]))
import asyncio
import logging
from shitgram import run_multiple_bots, Bot, types, enums
logging.basicConfig(level=logging.INFO)
bot_1 = Bot("API_TOKEN_1")
bot_2 = Bot("API_TOKEN_2")
@bot_1.onMessage()
@bot_2.onMessage()
async def on_message(bot: Bot, message: types.Message):
return await bot.sendMessage(
message.chat.id,
(await bot.getMe()).mention.markdown,
parse_mode=enums.ParseMode.MARKDOWN
)
asyncio.run(run_multiple_bots([bot_1, bot_2]))
FAQs
Python module based on https://core.telegram.org/bots/api
We found that shitgram demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.