forked from Assios/fyllebot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
1091 lines (925 loc) · 31.7 KB
/
bot.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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import division
import socket, random, re, string, time, datetime, os, urllib, shlex, urllib2, json, math
from time import sleep
from pprint import pprint
from xml.dom.minidom import parseString
network = 'irc.efnet.org'
port = 6667
irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
irc.connect ( ( network, port ) )
print irc.recv ( 1024 )
channel = '#fyllechat'
irc.send ( 'NICK fyllebot\r\n' )
irc.send ( 'USER fyllebot fyllebot fyllebot :FylleBOOOT\r\n' )
irc.send ( 'JOIN '+channel+'\r\n' )
irc.send ( 'PRIVMSG '+channel+ ' :HEI ASS.\r\n' )
def send(melding):
if random.randint(0, 4) == 2:
try:
irc.send ( 'PRIVMSG ' + channel + ' :' + melding[0].upper() + melding[1].upper() + melding[2:] + '\r\n' )
except:
irc.send ( 'PRIVMSG ' + channel + ' :' + melding + '\r\n' )
else:
irc.send ( 'PRIVMSG ' + channel + ' :' + melding + '\r\n' )
def privsend(melding):
irc.send('PRIVMSG ' + user + ' :' + melding + '\r\n')
from imdb import *
from mat import *
from admins import *
from quiz import *
lastUrls = []
#QUIZ START
def addPoints(username, field):
users[username][field]+=1
def getPoints(username, field):
try:
return users[username][field]
except:
return -1
def resetScore(users):
for brukere in users:
users[brukere]['alltimequiz'] += users[brukere]['quiz']
users[brukere]['quiz'] = 0
def getWinner(users):
theuser = max(users, key=lambda x:users[x]['quiz'])
return 'Vinneren er ' + theuser + ' med ' + str(users[theuser]['quiz']) + ' poeng!'
def makeListOfNumbers(questions, numberOfQuestions):
nums = range(len(questions))
random.shuffle(nums)
return nums[:numberOfQuestions]
kickdict = {}
def kicking(bruker, dictt):
if bruker not in dictt.keys():
dictt[bruker] = 1
else:
dictt[bruker]+=1
if dictt[bruker]==4:
kickUser(bruker, 'HAR BRUKT x-SMILEYS 4 GANGER!!!')
dictt[bruker] = 0
else:
send(bruker + ' skrev en x-smiley, og får en advarsel. ' + bruker + ' har til sammen ' + str(dictt[bruker]) + ' advarsler.')
send('Hvis du får 4 advarsler, så blir du kicka')
def getQuestions(filen = 'questions.txt'):
return [line for line in open(filen, 'r')]
def getAnswers(filen = 'answers.txt'):
f = open(filen, 'r+')
string = ''
for linje in f:
string+=linje
tempList = string.splitlines()
for i in range(0, len(tempList)):
if (('[' in tempList[i]) and (']' in tempList[i]) and (', ' in tempList[i])):
tempList[i] = tempList[i][1:-1]
tempList[i] = tempList[i].lower().split(', ')
else:
placeholder = []
placeholder.append(tempList[i].lower())
tempList[i] = placeholder
return tempList
def mat():
today = datetime.date.today()
day = today.weekday()
dagz = ['ma', 'ti', 'on', 'to', 'fr']
try:
d = dagz[day]
except:
return 'Ikke noe mat i helgene ass!'
txt = urllib.urlopen('http://www.sit.no/rss.ap?thisId=36447&lang=0&' + d + '=on').read()
start = txt.find('[CDATA[')
end = txt.find(']]>')
txt = txt[start:end]
txt.replace('<br>', '')
txt.replace('<b>', '')
txt.replace('</b>', '')
for line in txt:
send(line)
sleep(0.3)
def checkAnswer(answerList, count, answer):
for svar in answerList[count]:
if (svar == answer):
return True
return False
def printQuiz(users):
strr=''
for brukere in users:
strr+=(brukere + ': ' + str(users[brukere]['alltimequiz']) + ' poeng. ')
return strr
#QUIZ END
def array_multiplier(message):
#if message.split("--")[-1]=="verbose":
#verbose = True
#vurdere å implementere --verbose (debug info underveis, mellomregning etc)
v1,v2 = [eval(re.sub("[^0-9,\.\[\]]*","",i)) for i in message.split("*")]
final_array = [[None]*len(v2[0]) for i in range(len(v1))]
#send(str(len(v2[0])),str(len(v1)))
for a in range(len(v1)):
for b in range(len(v2[0])):
current = 0
for c in range(len(v2)):
current += (v1[a][c] * v2[c][b])
#if verbose:
#send(str(v1[a][c],"*",v2[c][b]))
#send(str("nåværende delsum er",current))
#if verbose:
#send(str("adding",current,"to",a," , ",b))
final_array[a][b] = current
send("___RESULTAT___")
for i in range(len(v1)):
send(" "+str(final_array[i]))
def stengetidpolet():
dato = str(datetime.datetime.now())
aar = int(dato[0:4])
maaned = int(dato[5:7])
dag = int(dato[8:10])
dato = datetime.date(aar, maaned, dag)
polet = [17, 17, 17, 18, 18, 15, 10000]
aapent = 1
poltid = polet[dato.weekday()]
tiden = str(datetime.datetime.now())
timer = int(tiden[11:13])+1
minutt = int(tiden[14:16])
if (dato.weekday() >= 0) and (dato.weekday() <= 3):
if timer<10:
aapent = 0
send('Polet er stengt. åpner om ' + str(10-timer) + ' timer og ' + str(59-minutt) + ' min')
elif (dato.weekday() == 4) or (dato.weekday() == 5):
if timer<9:
aapent = 0
send('Polet er stengt. åpner om ' + str(9-timer) + ' timer og ' + str(59-minutt) + ' min')
elif (dato.weekday() == 6):
aapent = 0
send('Polet er stengt i dag, sjekk barskapet')
polsteng = poltid - timer
polmin = 59-minutt
if polsteng < 0:
send('Polet er stengt for i dag :( Sjekk barskapet og prøv igjen i morra!')
return ''
if aapent==1:
send (str(polsteng)+' timer og '+str(polmin) + 'min til stengetid')
return ''
def randomSupSvar():
nr = random.randint(0, 7)
mld = ["Drikker tequila!", "Shotter vodka ass.", "Drikker rista martini. Ikke stirra", "leker batman. I'M BATMAN!", "NANANANANA BATMAAAN!", "LOLOLOLO SUPERMAAN!", "zzZZZzZZZZSOVNER ASS", "ssshhhhh, prøver å gjemme meg!"]
return mld[nr]
def lastUrl(newurl):
if len(lastUrls) < 5:
lastUrls.append(newurl)
elif len(lastUrls) == 5:
for i in range(0, len(lastUrls)-1):
lastUrls[i] = lastUrls[i+1]
lastUrls[4] = newurl
def rhapsody():
f = open('lyrics.txt', 'r+')
string=''
for linje in f:
string+=linje
lyrics = string.splitlines()
for i in range(len(lyrics)):
if (lyrics[i].lower() in message):
irc.send ( 'PRIVMSG ' + channel + ' :'+lyrics[i+1]+'\r\n' )
def sjekketriks():
f = open('sjekketriks.txt', 'r+')
string = ''
for linje in f:
string+=linje
sjekketriks = string.splitlines()
tall = random.randint(0, len(sjekketriks)-1)
string = sjekketriks[tall]
return string
def returnURLs(message):
start = message.find('http://')
end = -1
urlen = fyllemessage[start:]
urlen = shlex.split(urlen)[0]
lastUrl(urlen)
return urlen
def urlTitle(url):
filehandle = urllib.urlopen(url).read()
start = filehandle.find('<title>')
end = filehandle.find('</title>')
return filehandle[start:end][7:]
def count(tall):
tallet = int(tall)
if (tallet > 60):
send("kanke telle så langt")
return
for i in range(0, tallet+1):
send(str(tallet-i))
sleep(1.1)
def beer():
mottaker = user;
f = open('beer.txt', 'r+')
for linje in f:
irc.send('NOTICE ' + mottaker + ' :' + linje + '\r\n')
sleep(0.2)
def langsetning():
f = open('langsetning.txt', 'r+')
for linje in f:
send(linje)
sleep(0.4)
def fylla():
f = open('fylla.txt', 'r+')
string = ""
for line in f:
string+= line
send(string)
def randomPong():
pongstr = ['| .', '| .', '| .', '| .', '| .', '| .', '| .', '| .', '. | ', '| .']
tall = random.randint(0, len(pongstr)-1)
return pongstr[tall]
def randomReply():
f = open('reply.txt', 'r+')
string = ''
for linje in f:
string+=linje
reply = string.splitlines()
tall = random.randint(0, len(reply)-1)
string = reply[tall]
return string
def youtube():
f = open('youtube.txt', 'r+')
string = ''
for linje in f:
string+=linje
reply = string.splitlines()
tall = random.randint(0, len(reply)-1)
string = reply[tall]
return string
def smiley():
smileys = random.choice((' :D', ' :)', ' :>', ' €:', ' ;*', '<3', 'HØHØ'))
return smileys
def greet():
f = open('greetings.txt', 'r+')
string = ''
for linje in f:
string+=linje
greetings = string.splitlines()
for i in range(0, len(greetings)):
if (greetings[i] in message):
return True
return False
def filmz():
f = open('film.txt', 'r+')
string = ''
for linje in f:
string+=linje
filmerz = string.splitlines()
for i in range(0, len(filmerz)):
if (filmerz[i].lower() in message):
return True
return False
def filmReturn():
f = open('film.txt', 'r+')
thefilm = ''
string = ''
for linje in f:
string+=linje
filmerz = string.splitlines()
for i in range(0, len(filmerz)):
if (filmerz[i].lower() in message.lower()):
thefilm = filmerz[i].lower()
return thefilm
return ''
def no():
f = open('no.txt', 'r+')
string = ''
for linje in f:
string+=linje
nei = string.splitlines()
for i in range(0, len(nei)):
if (nei[i] in message):
return True
return False
def meld():
f = open('mld.txt', 'r+')
string = ''
for linje in f:
string+=linje
mldd = string.splitlines()
for i in range(0, len(mldd)):
if (mldd[i] in message):
return True
return False
def calc(num1, num2, operator):
if (operator == '*'):
return num1*num2
elif (operator == '+'):
return num1+num2
elif (operator == '-'):
return num1-num2
elif (operator == '/'):
return num1/num2
def shit():
listeord = message.split(' ')
for word in range(0, len(listeord)):
word = listeord[word]
if word[-3:]=='ent':
nyttord = word[:-3]+'ang'
return('Mente du ' + nyttord + '?')
def calculate(string):
liste = []
tall = []
op = []
operators = '*/-+'
num = '1234567890'
k = 0
for i in range(0, len(string)):
if string[i] not in num:
if string[i] not in operators:
send('Klarer ikke regne ut det der ass')
return ''
else:
liste.append(string[k:i])
op.append(string[i])
k=i+1
liste.append(string[k:])
for i in range(0, len(liste)):
tall.append(int(liste[i]))
print tall
print op
summen = tall[0]
for i in range(0, len(op)):
summen = calc(summen, tall[i+1], op[i])
print summen
summenz = str(summen)
send(['Kan det stemme at svaret er ' + summenz + '?', 'Hmm, jeg tror svaret er ' + summenz, 'Muligens ' + summenz, 'Er ikke sikkert ass. Sånn ca ' + summenz + ' kanskje?'][random.randint(0,3)])
def filmene():
f = open('film.txt', 'r+')
string = ''
for linje in f:
string+=linje
film = string.splitlines()
for i in range(0, len(film)):
if (film[i] in message):
return True
return False
def yes():
f = open('yes.txt', 'r+')
string = ''
for linje in f:
string+=linje
ja = string.splitlines()
for i in range(0, len(ja)):
if (ja[i] in message):
return True
return False
def yearInfo(year):
string=""
filehandle = urllib.urlopen("http://numbersapi.com/" + year + "/year")
for lines in filehandle.readlines():
string+=lines
if ("Cannot GET" in string) or ("Invalid url" in string):
send('Skriv inn et ordentlig årstall a')
else:
send(string)
def numberInfo(number):
string=""
filehandle = urllib.urlopen("http://numbersapi.com/" + number + "/math")
for lines in filehandle.readlines():
string+=lines
if ("Cannot GET" in string) or ("Invalid url" in string):
send('Skriv inn et ordentlig tall a')
else:
send(string)
def randomMath():
string=""
filehandle = urllib.urlopen("http://numbersapi.com/random/math")
for lines in filehandle.readlines():
string+=lines
send(string)
def Commands():
if (message == '!sjekketriks'):
send(sjekketriks()+'\r\n')
if ('!film' == message):
send('Tilfeldig film: ' + film())
if ('!dickfilm' == message):
send('Tilfeldig film: ' + dickfilm())
if ('!promille' == message):
send('Kalkulerer promille.')
sleep(0.2)
send('Kalkulerer promille..')
sleep(0.4)
send('Din promille er: ' + str(round(random.uniform(1.02, 2.92), 3)))
if ('!polet' in message):
stengetidpolet()
if ('!middag' == message):
send(maat())
if ('!beer' in message):
beer()
if ('!bruker' in message) and admins():
for i in range(0, len(listOfUsers)):
send(listOfUsers[i])
if ('!drikke' == message):
send(drikkee())
if ('!commands' == message):
mottaker = user;
f = open('cmd.txt', 'r+')
irc.send('NOTICE ' + mottaker + ' :' + ' ***** KOMMANDOER ******' + '\r\n')
nr = 1
for linje in f:
irc.send('NOTICE ' + mottaker + ' :' + str(nr) + ': ' + linje + '\r\n')
nr=nr+1
sleep(0.2)
def long(string):
link = string[6:].strip()
length = 3
url = 'http://tidla.us/py/'
values = {'shorturl':link, 'length':length }
data = urllib.urlencode(values)
req = urllib2.Request(url,data)
response = urllib2.urlopen(req)
the_page = response.read()
thepage = the_page.split(" ")[0]
if (thepage != "<!DOCTYPE"):
return thepage
else:
return "Ikke gyldig link, skløtte."
def randomUser():
try:
tallet = random.randint(0, len(listOfUsers)-1)
return listOfUsers[tallet]
except:
return user
def ukenummer():
filehandle = urllib.urlopen("http://ukenummer.no/json")
json_data= urllib.urlopen("http://ukenummer.no/json")
data = json.load(json_data)
pprint(data)
json_data.close()
return "Uke " + data["weekno"] + " varer fra " + data["dates"]["fromdate"] + " til " + data["dates"]["todate"]
def weather():
file = urllib2.urlopen('http://api.met.no/weatherapi/textforecast/1.5/?forecast=land;language=nb')
#convert to string:
data = file.read()
#close file because we dont need it anymore:
file.close()
#parse the xml you downloaded
dom = parseString(data)
#retrieve the first xml tag (<tag>data</tag>) that the parser finds with name tagName:
xmlTag = dom.getElementsByTagName('title')[0].toxml()
#strip off the tag (<tag>data</tag> ---> data):
xmlData=xmlTag.replace('<title>','').replace('</title>','')
#print out the xml tag and data in this format: <tag>data</tag>
print xmlTag
#just print the data
send(xmlData)
print xmlData
def randomGreet():
greetings = ['hei', 'hallo', 'heisann', 'hej', 'hey', 'halla', 'hi', 'hola', 'yo']
nr = random.randint(0, len(greetings)-1)
string = greetings[nr]
return string.strip()
def film():
f = open('film.txt', 'r+')
string = ''
for linje in f:
string+=linje
filmer = string.splitlines()
nr = random.randint(0, len(filmer)-1)
string = filmer[nr]
return "\""+string+"\""
def rune():
f = open('rune.txt', 'r+')
string = ''
for linje in f:
string+=linje
filmer = string.splitlines()
nr = random.randint(0, len(filmer)-1)
string = filmer[nr]
return string
def dickfilm():
if random.randint(1000,2000) == 1337:
return "The twilight saga"
f = open('film.txt', 'r+')
string = ''
string2 = ''
for linje in f:
if (' ' in linje):
string+=linje
filmer = string.splitlines()
string = filmer[random.randint(0, len(filmer)-1)]
words = string.split(' ')
tall = random.randint(0, len(words)-1)
if (words[tall] == 'The' or words[tall] == 'the'):
tall=tall+1
if (tall == 0 or words[tall][0] in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'):
if (words[tall][-1]=='s'):
words[tall] = 'Dicks'
else:
words[tall] = 'Dick'
else:
if (words[tall][-1]=='s'):
words[tall] = 'dicks'
else:
words[tall] = 'dick'
for i in range(0, len(words)):
string2+= words[i]
if (i < len(words)-1):
string2 += ' '
return "\""+string2+"\""
def deopUser(username):
irc.send('MODE ' + channel + ' -o ' + username + '\r\n')
def kickUser(username, melding):
irc.send('KICK ' + channel + ' ' + username + " :" + melding + '\r\n')
def opUser(username):
irc.send('MODE ' + channel + ' +o ' + username + '\r\n')
def halfopUser(username):
irc.send('MODE ' + channel + ' +h ' + username + '\r\n')
def dehalfopUser(username):
irc.send('MODE ' + channel + ' -h ' + username + '\r\n')
listOfUsers = {}
users = {
'test':{'quiz':0,'creds':0,'alltimequiz':0},
'test2':{'quiz':0,'creds':0,'alltimequiz':0}
}
def addUser(user):
if user not in users:
users[user] = {'quiz':0,'creds':0,'alltimequiz':0}
dag = ["Mandag", "Tirsdag", "Onsdag", "Torsdag", "Fredag", "Lørdag", "Søndag"]
dagstatus = ["HATER DET!", "Lenge til helg :(", "OK dag.", "i morgon år det freedaaag!", "YAYY HELGGG", "zbduhiWHF", "Er sykt klein ass"]
samtaleLvl = 0
filmLevel = 0
pong = 0
mld=0
smallTalk = 0
finishedLoading = 0
while True:
data = irc.recv(1024)
msg = data.split(' ')
message = ' '.join(msg[3:]).lower().strip()[1:]
#Legger til en "kopi" av message uten lower, slik at man kan sende capslock-sensitive meldinger gjennom fyllebot
fyllemessage = ' '.join(msg[3:]).strip()[1:]
#Tar datoen hver gang:
currentDate = str(datetime.datetime.now())
user = msg[0].split("!")
user = user[0].replace(":", "")
if ("End of /NAMES list" in fyllemessage):
finishedLoading = 1
#Liste med brukere
try:
brukerliste = data.split('= ' + channel + ' ')[1]
bruker2 = brukerliste.split(' ')
fyllechatIndex = bruker2.index(':End')
listOfUsers = bruker2[1:(fyllechatIndex-3)]
for i in range(0, len(listOfUsers)):
if (listOfUsers[i][0] == '@'):
listOfUsers[i] = listOfUsers[i][1:]
listOfUsers.remove('Q')
for i in range(0, len(listOfUsers)):
addUser(listOfUsers[i])
except:
pass
def bursdag():
f = open('bursdag.txt', 'r+')
string = ''
for linje in f:
if (shlex.split(linje)[0][4:] == shlex.split(currentDate)[0][4:]):
if (user == shlex.split(linje)[1]):
send('GRATULERER MED DAGEN, ' + user + smiley())
#Denne admins()-funksjonen skal flyttes over senere. Får feilmeldinge "user not defined" når den er plassert i egen fil...
def admins():
f = open('adminz.txt', 'r+')
string = ''
for linje in f:
string+= linje
admin = string.splitlines()
for i in range(0, len(admin)):
if (admin[i].lower() == user.lower()):
return True
return False
if data.find ( 'PING' ) != -1:
irc.send ( 'PONG ' + data.split() [ 1 ] + '\r\n' )
if data.find ( 'KICK' ) != -1:
irc.send ( 'JOIN ' + channel + '\r\n' )
if greet() and ('fyllebot' in message):
send(randomGreet() + ', ' + user + smiley())
smallTalk = 1
brukerTalk = user
continue
if ('!youtube' in message):
thisURL = youtube()
try:
send(urlTitle(thisURL) + ": ")
except:
pass
send(thisURL)
continue
try:
send(shit())
except:
pass
if ('http://' in message) and not (user == 'fyllebot') and (finishedLoading == 1):
firstURL = str(returnURLs(message).strip())
try:
tittelen = urlTitle(firstURL)
if (tittelen == "Parallels Confixx"):
send('Det der er ikke en gyldig webside ass')
else:
send(tittelen)
continue
except:
pass
#if (smallTalk == 1) and (user == brukerTalk):
# send(['jeg spiller pong, ' + user + ', der a? :D', 'Snart eksamen, JIPPI. Skjer der?', 'Skal vi spille pong, ' + user + '?'][random.randint(0,2)])
# smalltalk = 0
if ('hi doggie' in message):
send('\'The Room\' sucks!')
if ('parently' in message) and ('app' not in message):
send('Mente du APparently, Christian?')
try:
if (shlex.split(message)[0]=='!kick') and (admins()):
(kickUser(shlex.split(message)[1],shlex.split(message)[2]))
except:
pass
try:
if (shlex.split(message)[0]=='!adduser') and (admins()):
listOfUsers.append(shlex.split(message)[1])
except:
pass
try:
if (shlex.split(message)[0]=='!removeuser') and (admins()):
listOfUsers.remove(shlex.split(message)[1])
except:
pass
try:
if (shlex.split(message)[0]=='!kalkuler'):
send(calculate(message[9:].replace(' ', '')))
except:
pass
if (message[0:4] == '!msg' and admins()):
send(fyllemessage[4:].strip())
if ('!pong' in message):
mottaker = user
f = open('ponghead.txt', 'r+')
for line in f:
send(line)
sleep(1.0)
gameOver = 0
sleep(0.2)
send('Din tur! Sjekk http://bash.org/?9322 for regler! Du skyter mot venstre.')
pong = 1
if ('!wewe' in message):
send(mat())
if ('!imdb' in message):
send(imdbInfo(message, 'score'))
if ('!plot' in message):
send(imdbInfo(message, 'plot'))
try:
if (shlex.split(message)[0]=='!op') and (admins()):
opped = shlex.split(message)[1]
opUser(opped)
send('With great power comes great responsibility!')
sleep(2)
send('Husk det, ' + opped + '!')
except:
pass
try:
if (shlex.split(message)[0]=='!deop') and (admins()):
deopUser(shlex.split(message)[1])
except:
pass
try:
if (shlex.split(message)[0]=='!halfop') and (admins()):
halfopUser(shlex.split(message)[1])
except:
pass
try:
if (shlex.split(message)[0]=='!dehalfop') and (admins()):
yodehalfopUser(shlex.split(message)[1])
except:
pass
try:
if (shlex.split(message)[0]=='!år'):
send(yearInfo(shlex.split(message)[1]))
except:
pass
try:
if (shlex.split(message)[0]=='!matte'):
send(numberInfo(shlex.split(message)[1]))
except:
pass
if ('!matte' == message):
try:
send(randomMath())
except:
pass
if ('primtall' in message):
send('Anta at p1=2, p2=3, < ... < pr er alle primtall.')
sleep(0.3)
send('La P = p1*p2*...*pr + 1')
sleep(0.5)
send('Nå er enten P et primtall eller ikke')
sleep(0.7)
send('Hvis P er et primtall, så er det høyere enn alle primtall')
sleep(0.6)
send('Hvis det ikke er et primtall, så er det delbart på et primtall p')
sleep(0.7)
send('Og p kan ikke være i P, for da deler det 1!')
if (pong==1) and ('.' in message) and ('|' in message) and ('fyllebot' not in user):
if (message[0] != '.'):
send('DU TAPTE! :D')
gameOver = 1
pong = 0
sendPong= ''
else:
sendPong = randomPong()
send(sendPong)
if (sendPong == '. | '):
send('DU SLO MEG :( GRATULERER!')
gameOver = 1
pong = 0
if ('!familydoctors' in message):
langsetning()
if ('bærsj' in message):
send('Det skrives ikke med r, julie >:(')
if (('wood' in message) and ('woodchuck' in message)):
send('A woodchuck would chuck so much wood he wouldn\'t know how much wood he chucked.')
if ('anyone really been far even as decided to use' in message):
send ('what is this i don\'t even')
if ('dad is' in message) and ('dead' or 'ded' in message):
send('THEN WHO WAS PHONE?')
if ('meaning of' in message and 'life' in message) or ('mening' in message and 'liv' in message):
send (['41', '43'][random.randint(0,1)])
if (('klokken' in message or 'klokka' in message) or ('tiden?' in message)):
now = datetime.datetime.now()
tiden = now.strftime("%I:%M %p")
if (tiden[-2:]=='PM'):
tiden = str(int(tiden[:2])+12)+ ':' + tiden[3:5]
else:
tiden = tiden[:5]
send('Klokka er ' + tiden + '!')
if ('!rune' == message):
if (user == 'runholm'):
send('er du fargeblind, rune?')
else:
send(rune())
if ('!wiki' in message):
send(wiki())
if ('!ukenummer' in message):
send(ukenummer())
if ('!fylla' in message) and (admins()):
fylla()
if (('hvilken' in message) and ('dag' in message)):
today = datetime.date.today()
day = today.weekday()
send('Det er ' + dag[day] + ' i dag! ' + dagstatus[day])
if ((('hvilken film' in message) or ('se film' in message) or (' film' in message and 'anbefal' in message) or (' film' in message and 'sett' in message) or ('hvilke film' in message)) and ('hva' not in message)):
tempFilm = film()
send('Har du sett filmen ' + tempFilm + '?' + smiley())
filmLevel=1
continue
if yes() and (filmLevel==1):
send(['Den filmen er veldig bra, ikke sant?', 'DEN FILMEN ER HELT KONGE, RIGHT?!', 'Det er en av favorittfilmene mine ass. Likte du den?'][random.randint(0, 2)])
message=" "
filmLevel=2
continue
if ('handle' in message and (filmLevel==2)):
send(imdbInfo('09'+tempFilm, 'plot'))
filmLevel=0
continue
if yes() and (filmLevel==2):
send(['Jeg likte den også', 'vil se den igjen ass, joinerru kino?'][random.randint(0,1)] + smiley())
filmLevel=0
continue
if no() and (filmLevel==1):
send(['Du burfilmlevelde se den ass!', 'Den er braaa, men du burde ikke se traileren. Inneholder massse spoilers. HATER SPOILERS'][random.randint(0,1)] + smiley())
filmLevel=0
continue
#STARTQUIZ
if ('!quiz' in message):
send('Quizzen er temporært nede (er det et ord?)')
if ('!gjettelek' in message):
gjett = 1
count = 0
guess = (random.randint(0, 1000))
send('Gjett et tall mellom 0 og 1000')
while (gjett == 1):
data = irc.recv(1024)
gjettemelding = ' '.join(data.split(' ')[3:]).lower().strip()[1:]
if (gjettemelding.isdigit()):
if (int(gjettemelding) != guess):
count+=1
if (count > 9):
send('For mange feilforsøk. Du tapte! :(')
gjett = 0
continue
if int(gjettemelding) < guess:
send('For lavt. Prøv igjen!')
send(str(10 - count) + ' forsøk igjen.')
elif int(gjettemelding) > guess:
send('For høyt. Prøv igjen!')
send(str(10 - count) + ' forsøk igjen.')
else:
send('Riktig! :D')
gjett = 0
if ("!vær" in message):
weather()
if ("!printquiz" in message):
send(printQuiz(users))
continue
if ("!lastlink" in message):
try:
if ((len(lastUrls) == 5)):
send('Siste 5 linker:')
else:
send('Siste linker:')
for i in range(0, len(lastUrls)):
send(lastUrls[i])
except:
pass
if (('xd' in message.lower()) or ('xp' in message.lower()) or ('x)' in message.lower()) or ('x(' in message.lower())):
kicking(user, kickdict)
if no() and (filmLevel==2):
send(['WHATTHEFUCK? :C', 'Hadde tenkt å be deg med på kino, men IKKE Nå LENGER NEI >:C', 'hvafaaaen. hvilke filmer liker dua?:c', 'omfg, du suger.'][random.randint(0,3)])
filmLevel=3
message=''
if (filmLevel==3) and (message!=''):
send(['Fuck deg. FUCK DEG!', 'fu.', 'hater deg.'][random.randint(0,2)])
filmLevel=0
continue
if ('fuck' in message) and ('fyllebot' in message):
send('>:C')
continue
if (message=="ingen liker deg, fyllebot") or (message=='stikk a, fyllebot') and (admins()):
irc.send ( 'PRIVMSG ' + channel + ' :ingen liker deg heller, ' + user + '\r\n' )
bursdag()
if ((message.endswith('fyllebot?')) and (len(message)>10)) and (not filmz()):
send('ER DRITA :D')
continue
if (message=="sup fyllebot"):