def test_greet1(): # Set Up name = 'Ron' # Execute greeting = greet(name) # Validate assert (greeting == 'Hello, Ron!')
async def on_message(message): await client.change_presence(game=discord.Game(name='with Mommy.')) mess = message.content.lower() chan = message.channel auth = str(message.author) server = message.server storeModules = [storingQuotes.storeLastQuote, storingQuotes.storeQuote] retrieveModules = [ retrievingQuotes.getLastQuote, retrievingQuotes.getQuoteAtLine, retrievingQuotes.getRandomQuote ] if message.author == client.user: return else: response = greetings.greet(mess) if response != None and response != "": await client.send_typing(chan) await client.send_message(chan, response) response = greetings.gbye(mess) if response != None and response != "": await client.send_typing(chan) await client.send_message(chan, response) storingQuotes.tempStoreLastQuote(mess, auth) for function in storeModules: response = function(mess, chan, server, auth) if response != None and response != "": await client.send_typing(chan) await client.send_message(chan, response) break for function in retrieveModules: response = function(mess, server) if response != None and response != "": await client.send_typing(chan) await client.send_message(chan, response) break
def main_loop_iteration(self): # check for external input self.redis_input() # perform various passive operations if the interval is up if (datetime.utcnow() - self.last_passive).total_seconds() < self.passive_interval: return # check if any nicks with unread messages have come online (disabled for now) # unread_receivers = self.database.mail_unread_receivers() # if len(unread_receivers) > 0: # self._ison(unread_receivers) # check if it's time to talk if self.idle_talk: for channel in self.channels: if channel.idle_timer.can_talk(): seq_id = 0 quote = self.database.random_quote(channel=channel.name, stringify=False) if quote is not None: message, author, date, seq_id = quote self.send_message(channel.name, message) channel.add_history( 'idle talk', 'seq_id=%i, i=%i, d=%i' % (seq_id, channel.idle_timer.interval, channel.idle_timer.delay)) channel.idle_timer.message_sent( ) # notify idle timer that we sent something, even with no quote # check if it's time for a festive greeting for channel_name, greeting in greetings.greet(): channel = self.get_channel(channel_name) if channel is not None: self.send_message(channel_name, greeting) channel.add_history('greeting', greeting) self.last_passive = datetime.utcnow()
def main_loop_iteration(self): # check for external input self.redis_input() # perform various passive operations if the interval is up if (datetime.utcnow() - self.last_passive).total_seconds() < self.passive_interval: return # check if any nicks with unread messages have come online (disabled for now) # unread_receivers = self.database.mail_unread_receivers() # if len(unread_receivers) > 0: # self._ison(unread_receivers) # check if it's time to talk if self.idle_talk: for channel in self.channels: if channel.idle_timer.can_talk(): seq_id = 0 quote = self.database.random_quote(channel=channel.name, stringify=False) if quote is not None: message, author, date, seq_id = quote self.send_message(channel.name, message) channel.add_history( "idle talk", "seq_id=%i, i=%i, d=%i" % (seq_id, channel.idle_timer.interval, channel.idle_timer.delay), ) channel.idle_timer.message_sent() # notify idle timer that we sent something, even with no quote # check if it's time for a festive greeting for channel_name, greeting in greetings.greet(): channel = self.get_channel(channel_name) if channel is not None: self.send_message(channel_name, greeting) channel.add_history("greeting", greeting) self.last_passive = datetime.utcnow()
from greetings import greet greet()
import datetime import greetings as gr # import recogniseSpeech as rs import event_handler as event if __name__ == '__main__': gr.greet() cTime=datetime.datetime.now().minute while 1: # query = rs.takeCommand().lower() query = str(input('Command : ')).lower() print(datetime.datetime.now().minute) # if datetime.datetime.now().minute < cTime+1 or ('hey' in query): if True: cTime = datetime.datetime.now().minute event.handle_event(query) else: print('Something is not right')
import hy import greetings greetings.greet("Foo")
def test_greet3(self): self.assertNotEqual(greet('Charles'), 'Hello, Charlie!')
def test_greet2(self): self.assertEqual(greet('Ron'), 'Hello, Ron!')
import greetings greetings.greet("Bill")
def test_greet_the_world(): assert greet("world") == "Hello, world!"