Revert "Merge branch 'master' into webhook"
This reverts commit ca5e005caf3cdd6d55ee654f48d593f11e3b98d4, reversing changes made to 1c5866b88db034f7ee7ef043672a1421f4f45330. Reverting wrong merge
This commit is contained in:
parent
ca5e005caf
commit
7c744a8d23
5
LICENSE
5
LICENSE
@ -5,8 +5,9 @@ Copyright (c) 2017 Sergey
|
|||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, and to permit persons to whom
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
the Software is furnished to do so, subject to the following conditions:
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
The above copyright notice and this permission notice shall be included in all
|
||||||
copies or substantial portions of the Software.
|
copies or substantial portions of the Software.
|
||||||
|
10
README.md
10
README.md
@ -1,16 +1,10 @@
|
|||||||
# tgvkbot
|
# tgvkbot
|
||||||
Бот позволяет получать и отправлять сообщения VK находясь в Telegram
|
Бот позволяет получать и отправлять сообщения VK находясь в Telegram
|
||||||
|
|
||||||
|
Поддерживаются вебхуки и лонгполлинг, закомментируйте и раскомментируйте нужные строки
|
||||||
[](https://heroku.com/deploy)
|
|
||||||
|
|
||||||
|
|
||||||
[Ветка](https://github.com/Kylmakalle/tgvkbot/tree/webhook) для деплоя на локальной машине (поддерживаются вебхуки и лонгполлинг, закомментируйте и раскомментируйте нужные строки)
|
|
||||||
|
|
||||||
|
|
||||||
Настройка вебхуков по гайду от [@Groosha](https://www.gitbook.com/book/groosha/telegram-bot-lessons)
|
Настройка вебхуков по гайду от [@Groosha](https://www.gitbook.com/book/groosha/telegram-bot-lessons)
|
||||||
|
|
||||||
## Stay Tuned!
|
|
||||||
|
|
||||||
|
[Использование](https://www.asergey.me/tgvkbot/usage)
|
||||||
_Полноценные комментарии к коду будут чуть позже_
|
|
||||||
|
34
app.json
34
app.json
@ -1,34 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "tgvkbot",
|
|
||||||
"description": "Бот позволяет получать и отправлять сообщения VK находясь в Telegram",
|
|
||||||
"repository": "https://github.com/Kylmakalle/tgvkbot",
|
|
||||||
"keywords": ["vk", "bot", "telegram"],
|
|
||||||
"website": "https://asergey.me/tgvkbot/",
|
|
||||||
"buildpacks":[
|
|
||||||
{
|
|
||||||
"url": "heroku/python"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"env": {
|
|
||||||
"TELEGRAM_TOKEN": {
|
|
||||||
"description": "Telegram bot API токен от https://t.me/BotFather",
|
|
||||||
"value": "123456789:AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLL"
|
|
||||||
},
|
|
||||||
"VK_APP": {
|
|
||||||
"description": "ID VK приложения из https://vk.com/apps?act=manage",
|
|
||||||
"required": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"addons": [
|
|
||||||
{
|
|
||||||
"plan": "heroku-redis:hobby-dev",
|
|
||||||
"as": "Redis"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"formation": {
|
|
||||||
"bot": {
|
|
||||||
"quantity": 1,
|
|
||||||
"size": "free"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
16
bot.py
16
bot.py
@ -13,7 +13,9 @@ import time
|
|||||||
from PIL import Image
|
from PIL import Image
|
||||||
from telebot import types
|
from telebot import types
|
||||||
|
|
||||||
from credentials import token, vk_app_id
|
import cherrypy
|
||||||
|
|
||||||
|
from credentials import token, vk_app_id, bot_url, local_port
|
||||||
from vk_messages import VkMessage, VkPolling
|
from vk_messages import VkMessage, VkPolling
|
||||||
|
|
||||||
vk_threads = {}
|
vk_threads = {}
|
||||||
@ -22,7 +24,8 @@ vk_dialogs = {}
|
|||||||
|
|
||||||
FILE_URL = 'https://api.telegram.org/file/bot{0}/{1}'
|
FILE_URL = 'https://api.telegram.org/file/bot{0}/{1}'
|
||||||
|
|
||||||
vk_tokens = redis.from_url(os.environ.get("REDIS_URL"))
|
tokens_pool = redis.ConnectionPool(host='localhost', port=6379, db=0)
|
||||||
|
vk_tokens = redis.StrictRedis(connection_pool=tokens_pool)
|
||||||
|
|
||||||
currentchat = {}
|
currentchat = {}
|
||||||
|
|
||||||
@ -659,7 +662,6 @@ def reply_text(message):
|
|||||||
create_thread(message.from_user.id, code)
|
create_thread(message.from_user.id, code)
|
||||||
bot.send_message(message.from_user.id,
|
bot.send_message(message.from_user.id,
|
||||||
'Вход выполнен в аккаунт {} {}!'.format(user['first_name'], user['last_name'])).wait()
|
'Вход выполнен в аккаунт {} {}!'.format(user['first_name'], user['last_name'])).wait()
|
||||||
|
|
||||||
bot.send_message(message.from_user.id, '[Использование](https://asergey.me/tgvkbot/usage/)',
|
bot.send_message(message.from_user.id, '[Использование](https://asergey.me/tgvkbot/usage/)',
|
||||||
parse_mode='Markdown').wait()
|
parse_mode='Markdown').wait()
|
||||||
except:
|
except:
|
||||||
@ -676,9 +678,11 @@ def reply_text(message):
|
|||||||
except Exception:
|
except Exception:
|
||||||
bot.reply_to(message, 'Произошла неизвестная ошибка при отправке',
|
bot.reply_to(message, 'Произошла неизвестная ошибка при отправке',
|
||||||
parse_mode='Markdown').wait()
|
parse_mode='Markdown').wait()
|
||||||
|
print('Error: {}'.format(traceback.format_exc()))
|
||||||
|
|
||||||
bot.polling(none_stop=True)
|
|
||||||
"""class WebhookServer(object):
|
# bot.polling(none_stop=True)
|
||||||
|
class WebhookServer(object):
|
||||||
# index равнозначно /, т.к. отсутствию части после ip-адреса (грубо говоря)
|
# index равнозначно /, т.к. отсутствию части после ip-адреса (грубо говоря)
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def index(self):
|
def index(self):
|
||||||
@ -696,4 +700,4 @@ if __name__ == '__main__':
|
|||||||
cherrypy.config.update(
|
cherrypy.config.update(
|
||||||
{'server.socket_host': '127.0.0.1', 'server.socket_port': local_port, 'engine.autoreload.on': False,
|
{'server.socket_host': '127.0.0.1', 'server.socket_port': local_port, 'engine.autoreload.on': False,
|
||||||
'log.screen': False})
|
'log.screen': False})
|
||||||
cherrypy.quickstart(WebhookServer(), '/', {'/': {}})"""
|
cherrypy.quickstart(WebhookServer(), '/', {'/': {}})
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
import os
|
token = '123456789:hciowedjejd092jjasdasdmdkpoaasd'
|
||||||
token = os.environ['TELEGRAM_TOKEN']
|
vk_app_id = "5678910"
|
||||||
vk_app_id = os.environ['VK_APP']
|
bot_url = 'www.mybot.com'
|
||||||
|
local_port = 7777
|
@ -1,6 +0,0 @@
|
|||||||
pyTelegramBotAPI
|
|
||||||
vk
|
|
||||||
redis
|
|
||||||
Pillow
|
|
||||||
ujson
|
|
||||||
wget
|
|
@ -1 +0,0 @@
|
|||||||
python-3.6.1
|
|
@ -7,10 +7,9 @@ import vk
|
|||||||
import ujson
|
import ujson
|
||||||
import wget
|
import wget
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(format='%(levelname)-8s [%(asctime)s] %(message)s', level=logging.WARNING, filename='vk.log')
|
logging.basicConfig(format='%(levelname)-8s [%(asctime)s] %(message)s', level=logging.WARNING, filename='vk.log')
|
||||||
vk_tokens = redis.from_url(os.environ.get("REDIS_URL"))
|
tokens_pool = redis.ConnectionPool(host='localhost', port=6379, db=0)
|
||||||
|
vk_tokens = redis.StrictRedis(connection_pool=tokens_pool)
|
||||||
|
|
||||||
|
|
||||||
class VkPolling:
|
class VkPolling:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user