-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSellingBot.py
299 lines (250 loc) · 9.33 KB
/
SellingBot.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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
#Minecraft-Sprache: Deutsch
## GrieferBOT - Ein einfacher Verkaufsbot für Griefergames.net
## Copyright (C) 2018 LocutusV0nB0rg
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
warranty = """ GrieferBOT Copyright (C) 2018 LocutusV0nB0rg
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
"""
import time, os, re, datetime
from pynput.keyboard import Key, Controller, KeyCode
import pynput._util.win32_vks as VK
keyboard = Controller()
mouse = Controller()
Admins = ["LocutusV0nB0rg"]
SELLING = dict() #{1100:'beacon', 333:'Skull'}
INVENTORY = dict() #{'beacon':[(21, '1'), (41, '3')], 'Skull':[(42, '2')]}
SLOWCHAT = False
once = True
Ranksandsep = ["Spieler", "Ultra", "YouTuber", "Freund", "Freund+", "Premium", "Griefer", "Titan", "Legende", "Champ", "|"]
SellingRooms = {"LeftRoom":"", "RightRoom":""}
turned = "left"
dropKey = None
def output(out):
print(out)
out += '\n'
a = open('./logfile.txt', 'a+')
a.write(out)
a.close()
def push(key):
keyboard.press(key)
keyboard.release(key)
def quickSay(message):
output(message)
keyboard.press('t')
time.sleep(0.1)
keyboard.release('t')
keyboard.type(message)
time.sleep(0.2)
keyboard.press(KeyCode.from_vk(VK.RETURN))
time.sleep(0.1)
keyboard.release(KeyCode.from_vk(VK.RETURN))
def sayInChat(message):
global SLOWCHAT
output(message)
keyboard.press('t')
time.sleep(0.1)
keyboard.release('t')
keyboard.type(message)
time.sleep(0.2)
keyboard.press(KeyCode.from_vk(VK.RETURN))
time.sleep(0.1)
keyboard.release(KeyCode.from_vk(VK.RETURN))
if SLOWCHAT:
time.sleep(3.05)
else:
time.sleep(1.05)
def payPlayerAmount(player, amount):
sayInChat('/pay ' + player + ' ' + str(amount))
def msg(player, message):
sayInChat("/msg " + player + " " + message)
def dropItem(item):
global INVENTORY, dropKey
for thing in INVENTORY:
if thing == item:
for ele in INVENTORY[item]:
if ele[0]>0:
push(ele[1])
time.sleep(0.15)
push(dropKey)
ele[0] -= 1
confirm = 'Dropped ' + item
output(confirm)
return
def isReceivedItemAvailable(ItemName):
global INVENTORY
if ItemName not in INVENTORY:
return False
for ele in INVENTORY[ItemName]:
if ele[0] > 0:
return True
return False
def getItemByPrice(amount):
for key in SELLING:
if amount == key:
return SELLING[key]
return False
def follow(thefile):
thefile.seek(0,2)
while True:
line = thefile.readline()
if not line:
time.sleep(0.1)
continue
yield line
def getInv():
global INVENTORY, SELLING
i=0
while i<10:
i+=1
strin = 'Name des Items auf Slot ' + str(i) + ': '
item = input(strin)
if item == '':
return False
number = int(input('Wieviele Items sollen verkauft werden: '))
preis = int(input('Wieviel soll ein Item kosten: '))
if item not in INVENTORY:
INVENTORY[item] = [[number, str(i)]]
else:
INVENTORY[item].append([number, str(i)])
SELLING[preis] = item
def getAfkMessage():
print("Welche Nachricht soll dem Kunden angezeigt werden, wenn er eine Nachricht an den Bot schreibt?")
Message = input("(Leer lassen, wenn keine Nachricht angezeigt werden soll) :")
return Message
def toggleSlowchat():
global SLOWCHAT
SLOWCHAT = not SLOWCHAT
print(SLOWCHAT)
def turnLeft():
global mouse, turned
if turned != "left":
mouse.move(-1000, 0)
turned = "left"
def turnRight():
global mouse, turned
if turned != "right":
mouse.move(1000, 0)
turned = "right"
def getDropKey():
global dropKey
opfile = open(os.getenv("APPDATA")+"/.minecraft/options.txt", "r")
for line in opfile:
print(liste)
if "key_key.drop" in line:
liste = line.split('.')
print(liste)
dropKey = liste[-1]
print(dropKey)
if __name__ == '__main__':
print(warranty)
afk = getAfkMessage()
output(afk)
getInv()
getDropKey()
logfile = open(os.getenv("APPDATA")+"/.minecraft/logs/latest.log", "r")
loglines = follow(logfile)
time.sleep(5)
for line in loglines:
if "[Client thread/INFO]: [CHAT]" in line:
if once:
quickSay("Initialisiere GrieferBOT | Bitte warten...")
quickSay("Das sieht niemand... wenn doch, /msg LocutusV0nB0rg")
output('[+] Bestand zu Beginn des Durchlaufes')
output(str(INVENTORY))
output(str(SELLING))
output('[+] Bereit für Kunden.')
once = False
message = line[40:]
liste = message.split(' ')
liste.append('-')
liste.append('-')
liste.append('-')
########
if liste[0] == "Du":
SLOWCHAT = True
print(SLOWCHAT)
########
if liste[0] == "Please" and liste[1] == "wait":
SLOWCHAT = False
print(SLOWCHAT)
########
if liste[0] == "Der" and (liste[7] == "verlangsamt" or liste[7]=="auf") :
print(liste)
toggleSlowchat()
########
if afk != "":
if liste[0][0] == "[" and liste[3] == "->":
if "Teammitglieder" not in message and "Ränge" not in message:
output(message)
name = liste[2]
print(name)
msg(name, afk)
else:
sayInChat(liste[2] + " ist sehr warscheinlich ein Bot.")
time.sleep(1)
sayInChat(",")
time.sleep(1)
#######
if liste[3] == 'hat':
name = liste[2]
now = datetime.datetime.now()
strings = '[o] [' + now.strftime("%Y-%m-%d %H:%M") + '] Spieler: ' + name + ' | Betrag: ' + liste[5]
output(strings)
pre = liste[5][1:]
pre = re.sub(',', '', pre)
diff = float(pre)
item = getItemByPrice(diff)
print(item)
if not item:
payPlayerAmount(name, diff)
msg(name, 'Tut mir leid, aber ein Item mit diesem Preis scheint es nicht zu geben!')
else:
if isReceivedItemAvailable(item):
## if SellingRooms["LeftRoom"] == name:
## #turnLeft()
## dropItem(item)
## msg(name, 'Danke für ihren Einkauf!')
## elif SellingRooms["RightRoom"] == name:
## #turnRight()
dropItem(item)
msg(name, 'Danke für ihren Einkauf!')
## else:
## payPlayerAmount(name, diff)
## msg(name, 'Bitte begebe dich zuerst in eine der Kaufkammern.')
else:
payPlayerAmount(name, diff)
msg(name, 'Dieses Item ist leider ausverkauft. Hier hast du dein Money wieder!')
#######
now = datetime.datetime.now()
if int(now.strftime("%S"))%5==0 and liste[0][1:7] != "???????" :
quickSay("/near")
## if liste[1] == "in" and liste[3] == "Nähe:":
## data = liste [4:]
## for ele in data:
## if ele not in Ranksandsep and len(ele)>6:
## try:
## int(ele[-5])
## except:
## name = ele[:-5]
## distance = int(ele[-4])
## print(name, distance)
## if distance <= 3:
## sayInChat("/p kick " + name)
## if distance == 4:
## SellingRooms["RightRoom"] = name
## if distance == 5:
## SellingRooms["LeftRoom"] = name