-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.py
191 lines (156 loc) Β· 6.33 KB
/
start.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
import pickle
import discord
import random
import threading
import telegram.ext
import asyncio
import copy
import os
import sys
import time
import uuid
import math
import linecache
import sys
def PrintException():
exc_type, exc_obj, tb = sys.exc_info()
f = tb.tb_frame
lineno = tb.tb_lineno
filename = f.f_code.co_filename
linecache.checkcache(filename)
line = linecache.getline(filename, lineno, f.f_globals)
print('EXCEPTION IN ({}, LINE {} "{}"): {}'.format(filename, lineno, line.strip(), exc_obj))
#our shit
from commandHandler import CommandHandler, ChatUserInfo
import logging
#logging.basicConfig(level=logging.ERROR,
# format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
'''
for index in range(0, 1):
print(index)
with open("newtext" + str(index) + ".txt", "r") as file:
text = file.read()
text = text.replace(".", ". %END")
text = text.replace("- ", "")
for counter in range(0, 1):
chain.parse(text)'''
command = CommandHandler()
lastTimer = -606
def StartTelegram():
updater = telegram.ext.Updater("812651832:AAFyITJP_a0bn--9sfISeKiJMLf3rk8YnQ4", use_context = True)
dispatcher = updater.dispatcher
interestingCat = "πππππππππππππππ\nπππππππππππππππ\nπππππππππππππππ\nπππππππππππππππ\nπππππππππππππππ\nπππππππππππππππ\nπππππππππππππππ\nπππππππππππππππ\nπππππππππππππππ\nπππππππππππππππ\nπππππππππππππππ\nπππππππππππππππ\nπππππππππππππππ\nπππππππππππππππ\n"
def TInlineCallback(bot, update):
query = update.inline_query.query
results = [
telegram.InlineQueryResultArticle(
id = uuid.uuid4(),
title = "ΡΡΡ",
input_message_content = telegram.InputTextMessageContent(interestingCat))]
update.inline_query.answer(results)
telegramChannelCounter = {}
timers = {}
def message(update : telegram.Update, context : telegram.ext.CallbackContext):
if not update.message:
return
if update.message.from_user.name == "@DadaskisBot":
return
info = ChatUserInfo()
info.userName = update.message.from_user.first_name
info.userID = update.message.from_user.id
info.platform = "Telegram"
info.chatID = update.effective_chat.id
info.telegramBot = context.bot
info.telegramUpdate = update
if update.message.reply_to_message:
if update.message.reply_to_message.from_user.username == "DadaskisBot":
info.botReply = True
info.reply = True
info.userIDReply = update.message.reply_to_message.from_user.id
info.userNameReply = update.message.reply_to_message.from_user.name
print("send")
context.bot.send_message(chat_id = update.effective_chat.id, text = command.handle(update.message.text, info))
start_handler = telegram.ext.MessageHandler(telegram.ext.Filters.text, message)
dispatcher.add_handler(start_handler)
#dispatcher.add_handler(telegram.ext.InlineQueryHandler(TInlineCallback))
updater.start_polling()
TThread = threading.Thread(target = StartTelegram)
TThread.start()
class DiscordDudka(discord.Client):
async def on_ready(self):
print("Logged on as {0}!".format(self.user))
async def on_message(self, message):
#try:
if message.author == self.user:
return
if message.guild == None:
return
info = ChatUserInfo()
info.userName = message.author.nick
info.userID = message.author.id
info.platform = "Discord"
info.chatID = message.guild.id
#info.telegramBot = bot
#info.telegramUpdate = update
info.discordBot = self
info.discordMessage = message
messageString = command.handle(message.content, info)
if len(messageString) > 1:
await message.channel.send(messageString)
#except Exception as ex:
# PrintException()
# await self.logout()
# DStart()
def DStart():
try:
client = DiscordDudka()
client.run('NTIwODg0ODI4NDQzNTA4NzM2.XknWMg.Jgl-QHbzJJAKt2tPQU6vx3I9Gq8')
except Exception:
pass#DStart()
DStart()
'''
#print(update.message.chat_id)
#if random.randint(0, 100) <= 12:
chain.parse(update.message.text)
if telegramChannelCounter.get(str(update.message.chat_id)) == None:
telegramChannelCounter.update({str(update.message.chat_id) : 0})
# print("new " + update.message.chat)
replied = False
if update.message.reply_to_message:
if update.message.reply_to_message.from_user.name == "@DadaskisBot":
replied = True
global lastTimer
#global timers
#print(lastTimer, time.process_time())
#print(update.message.chat.description)
if (bot.get_chat(update.message.chat_id).description or "").find("DudkaNonStop") == -1:
if(timers.get(update.message.chat_id) == None):
timers[update.message.chat_id] = 0
if (timers[update.message.chat_id] + 0.1) > time.process_time():
#print("asd", lastTime, time.process_time())
return
try:
telegramChannelCounter[str(update.message.chat_id)] += 1
if TCommands(update) or replied or telegramChannelCounter[str(update.message.chat_id)] > 200:
#print(update.message.from_user.name + ", " + update.message.chat.username + ": " + update.message.text)
telegramChannelCounter[str(update.message.chat_id)] = 0
#for counter in range(1, 50):
lastText = update.message.text.lower()
lastText = lastText.replace("Π΄ΡΠ΄ΠΊΠ°, ", "")
lastText = lastText.replace("Π΄ΡΠ΄ΠΊΠ°,", "")
lastText = lastText.replace("Π΄ΡΠ΄ΠΊΠ°", "")
string = chain.getString(lastText)
for counter in range(1, 40):
newString = chain.getString(lastText)
newStringSet = newString.split(" ")
if len(newStringSet) > 30 and len(newStringSet) < 80:
if len(newString) < len(string):
string = newString
if len(string) > 4000:
string = string[:4000 - len(string)]
print("### Telegram msg: " + string)
bot.send_message(chat_id = update.message.chat_id, text = string)
timers[update.message.chat_id] = time.process_time()
except Exception as ex:
print(ex)
'''