Я пытаюсь написать предыдущий бот для (x) xchat. Сохранение и печать сообщений в порядке, но при его отправке не сохраняется сообщение.Переменная, отправляемая как пустое в сообщении
Я пробовал всевозможные методы, чтобы исправить это, но он всегда пуст.
Проблема Область:
for y in range(0, 14):
if msg_last[y]:
msg_to_say = 'privmsg ' + triggernick + ' <previously_bot> '
msg_to_say = msg_to_say + msg_last[y]
print (msg_to_say)
destination.command(msg_to_say)
Внутри Xchat он будет печатать:
privmsg <nick> <previously_bot> $msg
но при отправке его, это будет:
privmsg <nick> <previously_bot>
Можно ли определить, что я «Пропустили?
Полный код:
from random import randint
import xchat
__module_name__ = "Blake's Previous Messages Bot"
__module_version__ = " v0.1 "
__module_description__ = "A previous message bot"
print("\0034", __module_name__, __module_version__, __module_description__, "!\003")
#---Globals---#000000#FFFFFF----------------------------------------------------
msg_last = [str()] * 15
msg_count = 0
def on_chat(word, word_eol, userdata):
global msg_count
global msg_last
msg = word[1]
if msg_count == 15:
#print ("Full, reloading list")
for x in range(0, 14):
msg_last[x + 1] = msg_last[x]
msg_last[0] = msg
msg_count = 0
msg_last[msg_count] = msg
msg_count = msg_count + 1
def on_join(word, word_eol, userdata):
global msg_last
triggernick, triggerchannel, triggerhost = word
destination = xchat.get_context()
print ("Someone joined, pulling up log")
for y in range(0, 14):
if msg_last[y]:
msg_to_say = 'privmsg ' + triggernick + ' <previously_bot> '
msg_to_say = msg_to_say + msg_last[y]
print (msg_to_say)
destination.command(msg_to_say)
return xchat.EAT_ALL
def on_kevin(word, word_eol, userdata):
triggernick, triggerchannel, triggerhost = word
destination = xchat.get_context()
if triggernick == 'TenEighths':
rnd = randint(0,2)
if rnd == 2:
rnd2 = randint(0,3)
rnd_str = fuckYouKevin()
destination.command("say " + rnd_str)
#print ("Someone joined, pulling up log")
def fuckYouKevin(x):
return {
'0': 'stfu Kevin',
'1': 'omg TenEighths, will you stfu already?',
'2': 'Kevin is vomitting bullshit. Typical.',
'3': "Just cause you used an improper fraction doesn't mean your dick is bigger, TenEighths.",
}[x]
xchat.hook_print('Join', on_join)
xchat.hook_print('Channel Message', on_chat)
xchat.hook_print('Channel Message', on_kevin)