24
24
channels = ['nurdbottest' , 'nurds' , 'nurdsbofh' ] # TODO: channels to respond to
25
25
prefix = '!' # !command, will be updated by ghbot
26
26
db = 'summon.db'
27
- meshtastic_host = '10.208.43.239'
27
+ # meshtastic_host = '10.208.43.239'
28
28
29
29
# summoncfg.py should contain:
30
30
#xmpp_user = '...jabber account...'
38
38
cur .close ()
39
39
40
40
41
- def send_meshtastic (text ):
42
- global meshtastic_host
43
-
44
- if meshtastic_host != None :
45
- try :
46
- import meshtastic
47
- import meshtastic .tcp_interface
48
-
49
- iface = meshtastic .tcp_interface .TCPInterface (meshtastic_host )
50
-
51
- iface .sendText (text )
52
-
53
- n_nodes = len (iface .nodes .values ()) if iface .nodes else 0
54
-
55
- iface .close ()
56
-
57
- return n_nodes
58
-
59
- except Exception as e :
60
- print (f'{ time .ctime ()} Exception during "meshtastic": { e } , line number: { e .__traceback__ .tb_lineno } ' )
61
-
62
- return None
63
-
64
- def send_meshtastic_info ():
65
- global meshtastic_host
66
-
67
- if meshtastic_host != None :
68
- try :
69
- import meshtastic
70
- import meshtastic .tcp_interface
71
-
72
- iface = meshtastic .tcp_interface .TCPInterface (meshtastic_host , debugOut = sys .stdout )
73
-
74
- rc = iface .showInfo ()
75
-
76
- iface .close ()
77
-
78
- return rc
79
-
80
- except Exception as e :
81
- print (f'Exception during "meshtastic": { e } , line number: { e .__traceback__ .tb_lineno } ' )
82
-
83
- return None
41
+ # def send_meshtastic(text):
42
+ # global meshtastic_host
43
+ #
44
+ # if meshtastic_host != None:
45
+ # try:
46
+ # import meshtastic
47
+ # import meshtastic.tcp_interface
48
+ #
49
+ # iface = meshtastic.tcp_interface.TCPInterface(meshtastic_host)
50
+ #
51
+ # iface.sendText(text)
52
+ #
53
+ # n_nodes = len(iface.nodes.values()) if iface.nodes else 0
54
+ #
55
+ # iface.close()
56
+ #
57
+ # return n_nodes
58
+ #
59
+ # except Exception as e:
60
+ # print(f'{time.ctime()} Exception during "meshtastic": {e}, line number: {e.__traceback__.tb_lineno}')
61
+ #
62
+ # return None
63
+ #
64
+ # def send_meshtastic_info():
65
+ # global meshtastic_host
66
+ #
67
+ # if meshtastic_host != None:
68
+ # try:
69
+ # import meshtastic
70
+ # import meshtastic.tcp_interface
71
+ #
72
+ # iface = meshtastic.tcp_interface.TCPInterface(meshtastic_host, debugOut=sys.stdout)
73
+ #
74
+ # rc = iface.showInfo()
75
+ #
76
+ # iface.close()
77
+ #
78
+ # return rc
79
+ #
80
+ # except Exception as e:
81
+ # print(f'Exception during "meshtastic": {e}, line number: {e.__traceback__.tb_lineno}')
82
+ #
83
+ # return None
84
84
85
85
def summon (nick , text , by_whom , channel ):
86
86
global con
87
- global meshtastic_host
87
+ # global meshtastic_host
88
88
89
89
ok = True
90
90
91
- t = threading .Thread (target = send_meshtastic , args = (text ,))
92
- t .daemon = True
93
- t .start ()
91
+ # t = threading.Thread(target=send_meshtastic, args=(text,))
92
+ # t.daemon = True
93
+ # t.start()
94
94
95
95
cur = con .cursor ()
96
96
cur .execute ('SELECT email, jabber FROM entities WHERE nick=?' , (nick .lower (),))
97
97
98
98
row = cur .fetchone ()
99
99
if row == None :
100
- if meshtastic_host != None :
101
- return (False , 'Summoned via meshtastic' )
102
-
103
- else :
100
+ # if meshtastic_host != None:
101
+ # return (False, 'Summoned via meshtastic')
102
+ #
103
+ # else:
104
104
return (False , 'nothing registered for user' )
105
105
106
106
email = row [0 ]
@@ -148,10 +148,10 @@ def summon(nick, text, by_whom, channel):
148
148
return (False , f'Exception during "xmpp": { e } , line number: { e .__traceback__ .tb_lineno } ' )
149
149
150
150
if not email and not jabber :
151
- if meshtastic_host != None :
152
- return (False , 'Summoned via meshtastic' )
153
-
154
- else :
151
+ # if meshtastic_host != None:
152
+ # return (False, 'Summoned via meshtastic')
153
+ #
154
+ # else:
155
155
return (False , 'No summon protocol registered for that user' )
156
156
157
157
return (True , '' )
@@ -160,8 +160,8 @@ def announce_commands(client):
160
160
target_topic = f'{ topic_prefix } to/bot/register'
161
161
162
162
client .publish (target_topic , "cmd=summon|descr=Try to get someone's attention" )
163
- client .publish (target_topic , "cmd=meshtastic|descr=Try to get someone's attention via meshtastic" )
164
- client .publish (target_topic , "cmd=meshinfo|descr=Meshtastic state info" )
163
+ # client.publish(target_topic, "cmd=meshtastic|descr=Try to get someone's attention via meshtastic")
164
+ # client.publish(target_topic, "cmd=meshinfo|descr=Meshtastic state info")
165
165
166
166
def on_message (client , userdata , message ):
167
167
global prefix
@@ -212,31 +212,31 @@ def on_message(client, userdata, message):
212
212
except Exception as e :
213
213
client .publish (response_topic , f'Exception during "summon": { e } , line number: { e .__traceback__ .tb_lineno } ' )
214
214
215
- elif command == 'meshtastic' :
216
- try :
217
- only_nick = nick [0 :nick .find ('!' )]
218
-
219
- only_text = text [text .find (' ' ):].strip ()
220
-
221
- msg = f'{ only_nick } : { only_text } '
222
-
223
- n_nodes = send_meshtastic (msg )
224
-
225
- if n_nodes == None :
226
- client .publish (response_topic , 'Fail' )
227
-
228
- else :
229
- client .publish (response_topic , f'Sent to aprox. { n_nodes } nodes' )
230
-
231
- except Exception as e :
232
- client .publish (response_topic , f'Exception during "meshtastic": { e } , line number: { e .__traceback__ .tb_lineno } ' )
233
-
234
- elif command == 'meshinfo' :
235
- try :
236
- print (send_meshtastic_info ())
237
-
238
- except Exception as e :
239
- client .publish (response_topic , f'Exception during "meshinfo": { e } , line number: { e .__traceback__ .tb_lineno } ' )
215
+ # elif command == 'meshtastic':
216
+ # try:
217
+ # only_nick = nick[0:nick.find('!')]
218
+ #
219
+ # only_text = text[text.find(' '):].strip()
220
+ #
221
+ # msg = f'{only_nick}: {only_text}'
222
+ #
223
+ # n_nodes = send_meshtastic(msg)
224
+ #
225
+ # if n_nodes == None:
226
+ # client.publish(response_topic, 'Fail')
227
+ #
228
+ # else:
229
+ # client.publish(response_topic, f'Sent to aprox. {n_nodes} nodes')
230
+ #
231
+ # except Exception as e:
232
+ # client.publish(response_topic, f'Exception during "meshtastic": {e}, line number: {e.__traceback__.tb_lineno}')
233
+ #
234
+ # elif command == 'meshinfo':
235
+ # try:
236
+ # print(send_meshtastic_info())
237
+ #
238
+ # except Exception as e:
239
+ # client.publish(response_topic, f'Exception during "meshinfo": {e}, line number: {e.__traceback__.tb_lineno}')
240
240
241
241
def on_connect (client , userdata , flags , rc ):
242
242
client .subscribe (f'{ topic_prefix } from/irc/#' )
0 commit comments