Skip to content

Instantly share code, notes, and snippets.

View Kylmakalle's full-sized avatar

Sergey Akentev Kylmakalle

View GitHub Profile
@Kylmakalle
Kylmakalle / deleteMessageChecking.py
Created May 7, 2017 15:02
Script that checks bot possibility to delete messages
import requests
tokens = {
'123454321:abcdefghABCDEFGHIoqwe-123ejksdaaasd',
'987654321:xyzzyxABCabcTELEBOTadasd12389012nss',
'123456789:AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLL',
}
for token in tokens:
r = requests.get('https://api.telegram.org/bot{}/getMe'.format(token))
import telebot
import wget
token = '123456789:AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLL'
chatid = 12345678
bot = telebot.TeleBot(token)
file = 'http://dictionary.cambridge.org/media/english/uk_pron_ogg/u/ukh/ukhef/ukheft_029.ogg'
file = wget.download(file)
file = open(file, 'rb')
from telethon import TelegramClient
from telethon.tl.functions.channels import GetParticipantsRequest
from telethon.tl.types import ChannelParticipantsRecent
from telethon.utils import get_input_peer
api_id = 123456 # Use your own values here. https://my.telegram.org
api_hash = '0123456789abcdef0123456789abcdef'
phone_number = '+34600000000'
client = TelegramClient('%sessionname%', api_id, api_hash) # feel free to edit %sessionname% as you want
@Kylmakalle
Kylmakalle / video_note_test.py
Last active May 19, 2017 15:21
Testing send_video_note method in pyTelegramBotAPI
import telebot
token = '123456789:AAAbbbCccDDDEEEffFGGgHHhIIijjJ12345'
bot = telebot.TeleBot(token)
@bot.channel_post_handler(content_types=['video_note'])
def converting(message):
bot.get_file(message.video_note.file_id)
videonote = bot.download_file(bot.get_file(message.video_note.file_id).file_path)
if blocked.contains(users.ID == str(message.new_chat_member.id)):
bot.kick_chat_member(message.chat.id, message.new_chat_member.id)
bot.send_message(message.chat.id, '`' + message.new_chat_member.first_name + '`' + ' was blocked',
parse_mode='Markdown')
bot.send_message(me, '`' + message.new_chat_member.first_name + '`' + ' #id' + str(
message.new_chat_member.id) + ' was banned because of *BLOCK* in #{}'.format(message.chat.username),
parse_mode='Markdown')
blocked.remove(eids=[blocked.get(users.ID == str(message.new_chat_member.id)).eid])
from telethon import TelegramClient
from telethon.tl.functions.messages import GetFullChatRequest
api_id = 12345 # my.telegram.org
api_hash = 'n91hds91hd90qwd' # credenitals
phone_number = '+1231241213'
client = TelegramClient('telegram_script', api_id, api_hash) # feel free to edit %sessionname% as you want
client.connect() # logining and connecting to Telegram servers
# -*- coding: utf-8 -*-
import requests
s = requests.session()
URL = 'https://2ch.hk/'
BOARD = 'test'
THREAD = '31942'
# from moviepy.editor import *
# import telebot
# import threading
# ...receive message with link to .webm...
def convert_webm_to_mp4(message, m):
video = VideoFileClip(m.group(0))
converting = bot.reply_to(message, '<i>Конвертирую...</i>', parse_mode='HTML')
bot.send_chat_action(message.chat.id, 'upload_video')
{'animation': {'file_id': None,
'file_name': 'animation.gif.mp4',
'file_size': 192239,
'mime_type': 'video/mp4',
@Kylmakalle
Kylmakalle / main.py
Created August 6, 2017 19:10 — forked from gurland/main.py
How to delete all your messages from chat in telegram? Easy, just use this program
from telethon import TelegramClient
from telethon.errors import SessionPasswordNeededError
from telethon.tl.functions.messages import GetHistoryRequest
from telethon.tl.functions.channels import DeleteMessagesRequest
from telethon.tl.types.channel import Channel
import shelve
from os import listdir
from time import sleep
# Просто утилиты