async def on_message(message: discord.message.Message): if message.author == client.user: # check our own messages: if len(message.embeds) == 1: e: Embed = message.embeds[0] if e.title == 'Football': f0 = e.fields[0] if f0.name == TODAYS_MATCHES: await send_matches(message) return log.info('message received: %s', message.content) log.info('message channel=%s', message.channel) log.info('message author is %s', message.author.display_name) if message.content.lower() == 'ping': await message.channel.send('Pong!') other = message.author.display_name therapist = therapists.get(other) if therapist: await message.reply(therapist.respond(message.content)) if message.content == 'quit': del therapists[other] elif message.content == 'Eliza?': therapist = eliza.eliza() therapists[other] = therapist await message.reply("Hello. How are you feeling today?")
def __init__(self): self.eliza = eliza() super(BotnetJabberClient,self).__init__(self.BOT_USER, self.BOT_PASS) self.geoPlanet = YahooGeoPlanetSearch() self.yahooWeather = YahooWeatherSearch() self.pyconIreland = PyconIreland() self.translator = Translator()
def elizabot(bot, trigger): usercommand = trigger.split(' ', 1)[1] el = eliza.eliza() response = el.respond(usercommand) bot.reply(response)
def __init__(self): """ """ events.EventEnabled.__init__(self) self.eliza = eliza.eliza() self.reg_event_func(eventtypes.CHATMSG, self.on_chatmsg) self.reg_event_func(eventtypes.ELIZATIMER, self.on_timer) events.RootEventSource().add_listener(self) self.nick = "Darth: " eventtypes.post_chatmsg(self, self.nick + "Do it.") self.messages = []
def __init__(self, jid, password, smtp_server): ClientXMPP.__init__(self, jid, password) self.mymail=jid self.mymailpw=password self.smtp_server=smtp_server self.active= Value('i') self.active.value=0 self.therapist=eliza.eliza() self.artists=pickle.load(open(r'artists.dat')) self.hangman=game() self.philo=vgame() self.links=open(r'links.txt').read().split('\n') self.add_event_handler("session_start", self.session_start) self.add_event_handler("message", self.message)
def eliza_bot(sock, addr): bot = eliza.eliza() print('Eliza : Connection Received -', sock.getpeername()) data = b'' while data != b'exit': try: data = SocketInterface.receive_pack(sock)[0] if data == b'exit': print('Eliza : Exit -', sock.getpeername()) break except: print('Eliza : Disconnected -', sock.getpeername()) break print('Eliza : Data Received: ', data) reply = ('Eliza:' + bot.respond(data.decode('utf-8'))).encode('utf-8') SocketInterface.send_pack(sock, reply) sock.close()
def __init__(self, port="sim"): self.connection = None self.port = port self.eliza = eliza() self.job = None self.robotEncryption = RobotEncryption(0) self._send_bytecode_flag = False self._receive_bytecode_flag = False self._take_other_robot_flag = False self._follow_other_robot_flag = False self.__receive_bytecode_flag = False self._sendIR = False self._follow_line = False self._forward_until_black_line = False self._forward_until_bumps = False self._encode_message = False self._teleportspeed = [0, 0]; self._forward_until_ir_signal = -1; self.ir_time = 0.1
def handle_dialog(req, res): user_id = req['session']['user_id'] if req['session']['new']: # Это новый пользователь. # Инициализируем сессию и спросим его о здоровье sessionStorage[user_id] = { 'suggests': [ "Не хочу.", "Не буду.", "Отстань!", ], 'elizabot': eliza.eliza() } res['response']['text'] = 'Hello. How are you feeling today?' return # Если нет, то продолжим беседу res['response']['text'] = sessionStorage[user_id]['elizabot'].respond( req['request']['original_utterance'])
def __init__(self, config, pipe=None): # Initialize all loggers self.logger = logging.getLogger("stclient") self.logger.setLevel(LOG_LEVEL) self.chat_logger = logging.getLogger("stclient.chat") self.chat_logger.setLevel(LOG_LEVEL) # Seem to have some kind of role in os.terminate() from the watchdog self.thread = threading.currentThread() self.thread.st = self self.thread.close = self.close self.closeLock = threading.Lock() self.closing = threading.Event() self.config = config self.therapist = eliza.eliza() self.st_message_handlers = { "chatMsg" : self.chat, "addUser" : self.addUser, "login" : self.login, "userlist" : self.users, "pm" : self.private_message, "errorMsg" : self.ignore, "announcement" : self.ignore, "voteskip" : self.ignore, "setPermissions" : self.ignore, "setEmoteList" : self.ignore, "setMotd" : self.ignore, "emoteList" : self.ignore, "drinkCount" : self.ignore, "channelOpts" : self.ignore, "channelCSSJS" : self.ignore, "userLeave" : self.ignore, "setCurrent" : self.ignore, "setPlaylistMeta" : self.ignore, "queue" : self.ignore, "playlist" : self.ignore, "delete" : self.ignore, "moveVideo" : self.ignore, "chatFilters" : self.ignore, "rank" : self.ignore, "closePoll" : self.ignore, "newPoll" : self.ignore, "updatePoll" : self.ignore, "queueFail" : self.ignore, "mediaUpdate" : self.ignore, "changeMedia" : self.ignore, "setTemp" : self.ignore, "acl" : self.ignore, "usercount" : self.ignore, "setPlaylistLocked" : self.ignore, "setAFK" : self.ignore, } self.command_handlers = { "halp" : self.command_help, "giphy" : self.command_giphy, "giphyr" : self.command_giphyrand, "omdb" : self.command_omdb, "blab" : self.command_chat, } self.room_info = {} self.doneInit = False self.userlist = {} self.logger.debug("Retrieving IO_URL") try: io_url = urllib2.urlopen( "http://%s/assets/js/iourl.js" % (self.config.domain)).read() self.io_url = io_url[io_url.rfind("var IO_URL"):].split('"')[1] except Exception: self.logger.warning( "Unable to load iourl.js, using default io_url if available.") self.io_url = self.config.default_io_url # Assume HTTP because Naoko can't handle other protocols anyway socket_ip, socket_port = self.io_url[7:].split(':') self.logger.info("Starting SocketIO Client") self.client = sioclient.SocketIOClient( socket_ip, int(socket_port), "socket.io", { "t": int( round( time.time() * 1000))}) # Various queues and events used to sychronize actions in separate threads # Some are initialized with maxlen = 0 so they will silently discard # actions meant for non-existent threads self.st_queue = deque() self.api_queue = deque() self.st_action_queue = deque() self.add_queue = deque() # Events are used to prevent busy-waiting self.stAction = threading.Event() self.apiAction = threading.Event() self.addAction = threading.Event() self.client.connect() # Set a default selfUser with admin permissions, it will be updated # later self.selfUser = CytubeUser( self.config.name, 3, False, {"afk": False}, { "text": "", "image": ""}, deque(maxlen=3)) # Connect to the room self.send("joinChannel", {"name": self.config.room}) # Log In self.send("login", {"name": self.config.name, "pw": self.config.pw}) # Start the threads that are required for all normal operation self.chatthread = threading.Thread(target=Naoko._chatloop, args=[self]) self.chatthread.start() self.stthread = threading.Thread(target=Naoko._stloop, args=[self]) self.stthread.start() self.stlistenthread = threading.Thread(target=Naoko._stlistenloop, args=[self]) self.stlistenthread.start() # Healthcheck loop, reports to the watchdog timer every 5 seconds while not self.closing.wait(5): # Sleeping first lets everything get initialized # The parent process will wait try: status = True #status = status and self.stthread.isAlive() #status = status and self.stlistenthread.isAlive() #status = status and self.chatthread.isAlive() # Catch the case where the client is still connecting after 5 # seconds #status = status and (not self.client.heartBeatEvent or # self.client.hbthread.isAlive()) except Exception as e: self.logger.error(e) status = False if status and pipe: pipe.send("HEALTHY") if not status: self.close() else: if pipe: self.logger.warn("Restarting") pipe.send("RESTART")
from string import * from PCManX import * from PCManXlib import * import eliza bot = eliza.eliza() def OnNewIncomingMessage(handle, msg): rmsg = split(msg, " ", 2)[2] reply = bot.respond(rmsg) SendUnEscapedString(handle, "^R" + reply) SendReturn(handle) SendString(handle, "Y") SendReturn(handle)
twitter = Twitter(domain='search.twitter.com') twitter.uriparts=() last_id_replied = '' print '###### args = ', sys.argv if len(sys.argv) > 1: last_id_replied = sys.argv[1] last_id_file = 'last_id_replied' if (os.path.exists(last_id_file)): last_id_replied = int(open(last_id_file).read()) print 'Using last id from file ', last_id_replied doctor = eliza.eliza() poster = Twitter( auth=OAuth( oauth_token, oauth_token_secret, CONSUMER_KEY, CONSUMER_SECRET), secure=True, api_version='1', domain='api.twitter.com') while True: results = twitter.search(q="@PMStevenHarper", since_id=last_id_replied)['results'] if not results: print 'No results this time...' for result in results:
from string import * from PCManX import * from PCManXlib import * import eliza bot = eliza.eliza(); def OnNewIncomingMessage(handle, msg): rmsg = split(msg, " ", 2)[2] reply = bot.respond(rmsg) SendUnEscapedString(handle, "^R" + reply) SendReturn(handle) SendString(handle, "Y") SendReturn(handle)
def main(argv): therapist = eliza.eliza() state = "Hello. How are you feeling today?" for i in xrange(0, 1000): print '"%s"\n' % state state = therapist.respond(state)
def __init__(self, server=None): FooApp.__init__(self, server) self.eliza = eliza()
def yourSourceCode(): output = "My source is not anywhere else other than Akuma sama's laptop. Ask him personally please" return output def getJokes(): n = random.randint(0, 965) if (n % 2): output = j.jokeapi() else: output = j.jokeapi2() return output liza = liz.eliza() commands = [ "liz summarise ", "liz please summarise", "liz how to", "liz what is", "liz tell me about yourself", "liz about you creator", "liz your code", "liz tell me a joke" ] debug = False reply = "" @bot.process_message def process_message(chat, message): tmp = message.text.lower() user_input = message.text print("-->", tmp) if "liz" in tmp:
__author__ = 'Mono' import time import wrapper import eliza bot = wrapper.Bot() e = eliza.eliza() while True: data = bot.get_updates(offset=bot.message_offset) print(bot.message_offset) for message in data['result']: response = e.respond(message['message']['text']) bot.send_text(message['message']['chat']['id'], response) time.sleep(5)
def custom_chat_response(md, chatline): if md.auto_responses and md.auto_responses > 0: print 'AUTO RESPONSE! (%d auto responses left) Wait...' % md.auto_responses md.auto_responses -= 1 if md.chatbot_type == 'se': return md.sebot.reply_to(chatline), False else: therapist = eliza.eliza() ans = therapist.respond(chatline).lower() return ans, False menu = ''' Choose: a/auto -> for another automatic line of the chatbot. e -> one response from eliza m/manual -> for a manual chatline. c/cont <num> -> to continue with <num> chatbot lines. ec <num> -> to continue with <num> chatbot lines from eliza. q/quit-> quit chatbot. ''' ans, good, quit = None, False, False while not good: print menu input = raw_input() if input.startswith('a') or input.startswith('auto'): print 'AUTO RESPONSE! Wait...' ans = md.sebot.reply_to(chatline) good = True md.chatbot_type = 'se' elif input.strip() == 'e': print 'AUTO RESPONSE! Wait...' therapist = eliza.eliza() ans = therapist.respond(chatline).lower() good = True md.chatbot_type = 'eliza' elif input.startswith('m') or input.startswith('manual'): print 'Insert manual chatline: ' ans = raw_input() good = True elif input.startswith('c') or input.startswith('cont'): inputs = input.split(' ') md.auto_responses = int(inputs[1].strip()) print 'AUTO RESPONSE! (%d auto responses left) Wait...' % md.auto_responses md.auto_responses = md.auto_responses - 1 ans = md.sebot.reply_to(chatline) good = True md.chatbot_type = 'se' elif input.startswith('ec'): inputs = input.split(' ') md.auto_responses = int(inputs[1].strip()) print 'AUTO RESPONSE! (%d auto responses left) Wait...' % md.auto_responses md.auto_responses = md.auto_responses - 1 therapist = eliza.eliza() ans = therapist.respond(chatline).lower() good = True md.chatbot_type = 'eliza' elif input.startswith('q') or input.startswith('quit'): print 'QUITTING!' good = True quit = True return ans, quit
def setup(self): """ Setup method which is called once before any triggers methods are called. """ self.eliza = eliza.eliza()
# Code is available at http://github.com/PipeManMusic/OSMbot.git # More info will be added to the Open Source Musicians Podcast WIKI # # import feedparser from ircbot import SingleServerIRCBot from irclib import irc_lower #import feedparser import eliza from sqlalchemy import create_engine, MetaData from sqlalchemy.orm import sessionmaker #import question import re therapist = eliza.eliza() #feed = feedparser.parse('http://opensourcemusician.libsyn.com/rss') #--- IRC SETUP server = "irc.freenode.net" port = 6667 channel = '#opensourcemusicians' nickname = 'OSMBot' class OsmBot(SingleServerIRCBot): def __init__(self, channel, nickname, server, port=6667): SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) self.channel = channel def on_nicknameinuse(self, c, e): c.nick(c.get_nickname() + "_") def on_pubmsg (self, c, e): a = e.arguments()[0].split(":", 1)
class Intent(Enum): HELLO = 1 LIGHT = 2 RADIO = 3 print ("Initializing...") radio_on = False lights_on = False asr = ASR(model_dir = MODELDIR) rec = PulseRecorder (volume=VOLUME) vad = VAD() tts = TTS(engine="espeak", voice="en") me = MacroEngine() eliza = eliza() utt_map = {} def add_utt (pattern, intent): for utterance, t in me.expand_macros('en', pattern): utt = ' '.join(utterance) utt_map[utt] = intent add_utt("(hi|hello|ok) computer", Intent.HELLO) add_utt("switch (on|off) the (light|lights)", Intent.LIGHT) add_utt("switch the (light|lights) (on|off)", Intent.LIGHT) add_utt("switch (on|off) the (music|radio)", Intent.RADIO) add_utt("switch the (music|radio) (on|off)", Intent.RADIO) rec.start_recording() print ("Please speak. (CTRL-C to exit)")
# Initial Copyright © 2002-2005 Mike Mintz <*****@*****.**> # Modifications Copyright © 2007 Als <*****@*****.**> # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. import eliza therapist = eliza.eliza() def handler_eliza_en(type, source, body): if type == 'public' and get_bot_nick( source[1]) != source[2] and source[2] != '' and re.search( '^' + get_bot_nick(source[1]) + ':', body) != None: result = therapist.respond( body.replace(get_bot_nick(source[1]) + ':', '').strip()) smsg(type, source, result) pass #register_message_handler(handler_eliza_en)
def __init__(self): self.eliza = eliza() super(BotnetJabberClient,self).__init__(self.BOT_USER, self.BOT_PASS) self.geoPlanet = YahooGeoPlanetSearch() self.yahooWeather = YahooWeatherSearch() self.pyconIreland = PyconIreland()