teelive
| Added on 2009-02-07 03:33:29 |
0
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
#$ neutron_plugin 01 # -*- coding:Utf-8 -*- # # Plugin who can say what's currently happening on a teeworlds server # # © 2009 Le Coz Florent <louizatakk@fedoraproject.org> # # Licensed under WTFPL Version 2 as published by Sam Hocevar # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION # # 0. You just DO WHAT THE FUCK YOU WANT TO. import gobject # the file where the server's message are located # must be readable at least FILE = '/home/manu/teeworlds_out' # the room where you want the messages to be sent ROOM = 'teeworlds@chat.jabberfr.org' class Teelive(object): def __init__(self): self.last = ''; self.started = True self.weapons={'0': 'le marteau', '1': 'le pistolet', '2': 'le shotgun', '3': 'le bazooka', '4': 'le laser', '5': 'le katana'} def get_last_event(self): if not self.started: return True fd = open(FILE, 'r') new = fd.readlines()[-1] if new != self.last: if self.last != '': self.parse_line(new) self.last = new return True else: return True def parse_line(self, p): if 'leave player' in p: ms = p[p.find(":", p.find(":")+1)+1:-2] + ' a quitté la partie.' elif 'team_join' in p: ms = p.split("'")[1][p.split("'")[1].find(":")+1:] + ' a rejoint la partie.' elif 'kill' in p.split(): n = p.find("killer='") + len("killer='") + 2 m = p.find("' victim='") o = p.find("' weapon=") killer = p[n:m] victim = p[m+len("' victim='")+2:o] weapon = p[o+len("' weapon="):o+len("' weapon=")+1] if killer == victim: ms = killer + ' s\'est suicidé' else: ms = killer + ' a tué ' + victim try: ms += ' avec ' + self.weapons[weapon] + '.' except: ms += ' avec le décor, sûrement.' else: return False msg(ROOM, ms) return True def start(self, *args): if self.started == False: msg(ROOM, "Je vais être causant, pour m'arrêter, dites « !tg »") self.started = True def stop(self, *args): if self.started == True: msg(ROOM, "Ok, je me tais.") self.started = False teelive = Teelive() register_command_handler(teelive.start, '!teelive') register_command_handler(teelive.stop, '!tg')

