def __init__(self, host, port, nick, channels = [], chatlevel = 1, responsedelay = 0.3): self.host = host self.port = port self.nick = nick self.channels = channels self.buffer = [] self.chatlevel = chatlevel self.succinct = False self.listening = True self.AI = aiml.Kernel() self.IRC = irc(self.host,self.port,self.nick) self.listen = [] self.prevsender = "" self.responsedelay = responsedelay
""" cmd = "lp -d HP_LaserJet_500_colorMFP_M570dn -o media=a4 {pdf}".format( pdf=questionnaire_pdf) print(cmd) os.system(cmd) print('First PDF (questionnaire selection) is printing ...') # * * * * * * * * * # START SCENE 2 # # Elaine as Shadow Library librarian # * * * * * * * * * """ Start the IRC session with the Shadow Library librarian. """ irc("bs_user") # start the IRC chat in #beyondsocial at freenode # irc module listens to #shadowlibrary key to collect PDF(s) from Shadow Library. # A PDF can be selected by using the id number from the shadow_library.csv file. # For example: #shadowlibrary 7 """ Resize the selected PDF to A4. """ shadow_library_pdf = 'shadow_library.pdf' shadow_library_pdf_a4 = 'shadow_library_A4.pdf' cmd_resize_SL = "pdfjam --outfile {} --paper a4paper {}".format( shadow_library_pdf_a4, shadow_library_pdf) os.system(cmd_resize_SL) """ Print Shadow Library PDF. """ cmd = "lp -d HP_LaserJet_500_colorMFP_M570dn -o media=a4 {pdf}".format(
#!/usr/local/bin/env python3 #-*- coding = utf-8 -*- from checker import check import irc import sql import user i = irc.irc() s = sql.sql() with s: i.irc_conn() i.login() for ch in s.show_channels(): i.add_channel(ch[1]) i.join_all() while (1): try: buffer = i.IRC.recv(1024).decode("iso-2022-jp") except UnicodeDecodeError as e: buffer = "ERROR: UnicodeDecodeError" msg = buffer.split() print(msg) #PING PONG if msg[0] == "PING": i.send_data("PONG %s" % msg[1]) if len(msg) >= 4 and msg[1] == "PRIVMSG": check(buffer, msg, i, s) """
botowner = input("Please enter the bot admin's IRC nick:") config_json['botowner'] = botowner file = open("config.json",'w') file.write(json.dumps(config_json)) file.close() try: print("The battle channel is currently set to: %s" % config_json['battle_channel']) except KeyError: print("*** WARNING: There is no battle channel set. Please fix this now.") battlechannel = input("Please enter the IRC channel you're using (include the #):") config_json['battle_channel'] = battlechannel file = open("config.json",'w') file.write(json.dumps(config_json)) file.close() x = irc.irc() x.connect() x.login("ChromaBot", "8", "Herena", "Python socket RAW IRC BOT") buffer = b"" while True: buffer += x.IRC.recv(2048) while b"\r\n" in buffer: line_data, buffer = buffer.split(b"\r\n", 1) ld = decode(line_data) re_line = irc_line_re.match(ld) data = ld.split() print(re_line.groups()) if re_line is None: continue
parser.add_argument("nick", help="nickname of bot") # Optional parser.add_argument( "-c", "--channel", help= "join channels after connecting; multiple channels can be joined by providing a comma seperated list, such as: #a,#b,#c" ) parser.add_argument( "--rootpwd", help= "set root password, if left empty no root account exists (requires auth module)" ) args = parser.parse_args() chans = [] rootpwd = "" if args.channel: chans = [args.channel] if chans[0].find(",") != -1: chans = args.channel.split(",") if args.rootpwd: rootpwd = args.rootpwd # Handle args import irc i = irc.irc(args.server, args.nick, 6667, chans, rootpwd) i.run()
import time, config, pid, irc, db, log pid = pid.pid() irc = irc.irc() db = db.db() log = log.log() db.get_raffle_status() if pid.oktorun: try: while True: time.sleep(1) # Output out = db.get_next_output(time.time()) if out: sendStr = 'PRIVMSG '+ out[1] +' :'+ out[2] +'\n' print(sendStr) irc.sendmsg(sendStr) log.logmsg(sendStr, False) db.delete_output(out[0]) try: msg = irc.getmsg() print(msg) # Reconnect if disconnected if len(msg) == 0: irc.connect() # Prevent Timeout
print_line() lex_obj = lex('test/case_09.txt') lex_obj.test() print('\nSyn') print_line() syn_obj = syn(lex_obj) syn_obj.build() syn_obj.test() print('\nSemantics') print_line() semantics_obj = semantics(syn_obj) semantics_obj.check() print('\nIrGenerate') print_line() irc_obj = irc(semantics_obj) irc_obj.generate() print('\nTreeOptimizer') print_line() topt_obj = treeOptimizer(semantics_obj) topt_obj.generate() print('\nCodeOptimizer') print_line() copt_obj = codeOptimizer(r"result\treeOptimizeCode.txt") copt_obj.optimize()