-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsendMessage.py
147 lines (143 loc) · 6.79 KB
/
sendMessage.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
import telebot
message_rocket = ""
message_lockmodul = ""
class sendMessage():
counter = 0
lastMessage = ""
messageID = 0
chatID = 0
sleepTime = 0
maxCounter = 0
bot = ""
def sendMessageFull(self,create):
message = create.message
if len(self.lastMessage) == len(message):
time.sleep(self.sleepTime)
else:
if (len(self.lastMessage) <= len(create.message_lockmodul)) or (self.counter >= self.maxCounter):
try:
self.bot.delete_message(self.chatID,self.messageID)
id = self.bot.send_message(self.chatID, message, parse_mode='HTML',disable_web_page_preview=True,disable_notification=True) ##Nachricht traunstein quests
self.messageID = id.message_id
self.counter = 0
except:
print("Nachricht konnte nicht entfernt werden")
try:
id = self.bot.send_message(self.chatID, message, parse_mode='HTML',disable_web_page_preview=True,disable_notification=True) ##Nachricht traunstein quests
self.messageID = id.message_id
self.counter = 0
except:
print("Nachricht konnte weder entfernt noch neu versendet werden")
self.lastMessage = message
time.sleep(self.sleepTime)
else:
try:
id = self.bot.edit_message_text(message,chat_id=self.chatID, message_id=self.messageID, parse_mode='HTML',disable_web_page_preview=True) ##Nachricht traunstein quests
self.messageID = id.message_id
self.lastMessage = message
except:
try:
self.bot.delete_message(self.chatId,self.messageID)
id = self.bot.send_message(self.chatID, message, parse_mode='HTML',disable_web_page_preview=True,disable_notification=True) ##Nachricht traunstein quests
self.counter = 0
self.messageID = id.message_id
self.lastMessage = message
except:
print("Nachricht konnte weder editiert noch entfernt werden, versuche zu senden")
try:
id = self.bot.send_message(self.chatID, message, parse_mode='HTML',disable_web_page_preview=True,disable_notification=True) ##Nachricht traunstein quests
self.counter = 0
self.messageID= id.message_id
self.lastMessage = message
except:
print("Nachricht konnte weder editiert,entfernt oder gesendet werden")
self.counter +=1
time.sleep(self.sleepTime)
def sendMessageRocket(self,message):
if len(self.lastMessage) == len(message):
time.sleep(self.sleepTime)
else:
if self.counter >= self.maxCounter:
try:
self.bot.delete_message(self.chatID,self.messageID)
id = self.bot.send_message(self.chatID, message, parse_mode='HTML',disable_web_page_preview=True,disable_notification=True) ##Nachricht traunstein quests
self.counter = 0
self.messageID = id.message_id
self.lastMessage = message
except:
print("Nachricht konnte nicht entfernt werden, versuche zu senden")
try:
id = self.bot.send_message(self.chatID, message, parse_mode='HTML',disable_web_page_preview=True,disable_notification=True) ##Nachricht traunstein quests
self.counter = 0
self.messageID = id.message_id
self.lastMessage = message
except:
print("Nachricht konnte weder editiert,entfernt oder gesendet werden")
else:
try:
id = self.bot.edit_message_text(message,chat_id=self.chatID, message_id=self.messageID, parse_mode='HTML',disable_web_page_preview=True) ##Nachricht traunstein quests
self.messageID = id.message_id
self.lastMessage = message
except:
try:
self.bot.delete_message(self.chatId,self.messageID)
id = self.bot.send_message(self.chatID, message, parse_mode='HTML',disable_web_page_preview=True,disable_notification=True) ##Nachricht traunstein quests
self.counter = 0
self.messageID = id.message_id
self.lastMessage = message
except:
print("Nachricht konnte weder editiert noch entfernt werden, versuche zu senden")
try:
id = self.bot.send_message(self.chatID, message, parse_mode='HTML',disable_web_page_preview=True,disable_notification=True) ##Nachricht traunstein quests
self.counter = 0
self.messageID= id.message_id
self.lastMessage = message
except:
print("Nachricht konnte weder editiert,entfernt oder gesendet werden")
self.counter +=1
time.sleep(self.sleepTime)
def sendMessageLockmodul(self,message):
if len(self.lastMessage) == len(message):
time.sleep(self.sleepTime)
elif len(self.lastMessage) >= len(message):
try:
id = self.bot.edit_message_text(message,chat_id=self.chatID, message_id=self.messageID, parse_mode='HTML',disable_web_page_preview=True) ##Nachricht traunstein quests
self.messageID = id.message_id
self.lastMessage = message
except:
try:
self.bot.delete_message(self.chatId,self.messageID)
id = self.bot.send_message(self.chatID, message, parse_mode='HTML',disable_web_page_preview=True,disable_notification=True) ##Nachricht traunstein quests
self.messageID = id.message_id
self.lastMessage = message
except:
print("Nachricht konnte weder editiert noch entfernt werden, versuche zu senden")
try:
id = self.bot.send_message(self.chatID, message, parse_mode='HTML',disable_web_page_preview=True,disable_notification=True) ##Nachricht traunstein quests
self.messageID= id.message_id
self.lastMessage = message
except:
print("Nachricht konnte weder editiert,entfernt oder gesendet werden")
time.sleep(self.sleepTime)
else:
try:
self.bot.delete_message(self.chatID,self.messageID)
id = self.bot.send_message(self.chatID, message, parse_mode='HTML',disable_web_page_preview=True,disable_notification=True) ##Nachricht traunstein quests
self.messageID = id.message_id
except:
print("Nachricht konnte nicht entfernt werden")
try:
id = self.bot.send_message(self.chatID, message, parse_mode='HTML',disable_web_page_preview=True,disable_notification=True) ##Nachricht traunstein quests
self.messageID = id.message_id
except:
print("Nachricht konnte weder entfernt noch neu versendet werden")
self.lastMessage = message
time.sleep(self.sleepTime)
def setConfig(self,token,chatID,sleepTime,maxCounter):
self.chatID = chatID
self.sleepTime = int(sleepTime)
self.maxCounter = int(maxCounter)
self.bot = telebot.TeleBot(token)