How to receive files with python IRC bot? -


i've created semi-functional irc bot in python following sample code:

import socket import time import random import os  def stringtobytes(s):     blit = ""     char in s:         blit += char     return bytes(blit, "utf-8")  server = "irc.irchighway.net"  # settings channel = "#ebooks" botnick = "noobbot"  irc = socket.socket(socket.af_inet, socket.sock_stream)  # defines socket  irc.connect((server, 6667))  # connects server irc.send(stringtobytes("user " + botnick + " " + botnick + " " + botnick + " :this fun bot!\n"))  # user authentication irc.send(stringtobytes("nick " + botnick + "\n"))  # sets nick irc.send(stringtobytes("privmsg nickserv :inoope\r\n"))  # auth time.sleep(4) irc.send(stringtobytes("join " + channel + "\n"))  # join channel irc.send(stringtobytes("privmsg #ebooks @search save cat\r\n"))   while 1:  # puts in loop     text = irc.recv(2040)  # receive text     text2 = str(text)[2:]     text3 = text2.split(":")     print(text3) 

just test, these search book "save cat" in ebooks channel. works, , following showing in received text log:

['', 'search!search@ihw-4q5hcb.dyn.suddenlink.net notice noobbot ', '\x031,9\x16\x02<>\x02\x16 search "\x0312,9save cat\x031,9" has been accepted. searching...\r\n\''] ['', 'search!search@ihw-4q5hcb.dyn.suddenlink.net notice noobbot ', '\x031,9\x16\x02<>\x02\x16 search "\x0312,9save cat\x031,9" returned 55 matches. sending results as\x0312 searchbot_results_for_ save cat.txt.zip\x031,9. search took 0.33 seconds.\r\n\''] ['', 'search!search@ihw-4q5hcb.dyn.suddenlink.net notice noobbot ', 'dcc send searchbot_results_for_ save cat.txt.zip (173.80.26.71)\r\n', 'search!search@ihw-4q5hcb.dyn.suddenlink.net privmsg noobbot ', "\x01dcc send searchbot_results_for__save_the_cat.txt.zip 2907707975 3107 3966\x01\r\n'"]

if running in mirc, able click link download file, don't see link actual file anywhere in text. i'm new irc bots, example helpful.

i trying make own small client in python can input searches , client download resulting search text file when it's sent.

any appreciated


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -