Tanner Collin 4 лет назад
Сommit 76d74d06e6
  1. 114
      .gitignore
  2. 5
      requirements.txt
  3. 37
      sophiebot.py

114
.gitignore поставляемый

@ -0,0 +1,114 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
# Editor
*.swp
*.swo
# DB
db.sqlite3
# nodejs
node_modules/
# tbot specific:
*.session
*.session-journal
telethon/

@ -0,0 +1,5 @@
pkg-resources==0.0.0
pyaes==1.6.1
pyasn1==0.4.8
rsa==4.0
Telethon==1.10.8

@ -0,0 +1,37 @@
import asyncio
import json
# Change this:
USER_PHONE = '+19705736497'
from telethon.sync import TelegramClient, events, utils
TELETHON_SPAM = -1001382672427
BWB = -1001146421621
HORSESHOE = -1001269329011
SESSION = 'telethon'
API_ID = '929249' # semi-secret
API_HASH = '00c171d347a5140ddf2212157ab2a37a' # semi-secret
client = TelegramClient(SESSION, API_ID, API_HASH, sequential_updates=True)
client.start(USER_PHONE)
@client.on(events.NewMessage(chats=(HORSESHOE)))
async def new_message(event):
text = event.raw_text
print('[{}]: {}'.format(event.sender.first_name, text))
if text and len(text) < 1000:
m = {}
m['chat_id'] = event.chat_id
m['mid'] = event.id
m['from_id'] = event.sender_id
m['raw_text'] = event.raw_text
j = json.dumps(m)
await client.send_message(BWB, j)
print('Loaded.')
asyncio.get_event_loop().run_forever()
Загрузка…
Отмена
Сохранить