def handle_command(command, channel): """ Executes bot command if the command is known """ # Default response is help text for the user default_response = "Not sure what you mean. Try *{}*.".format( EXAMPLE_COMMAND) # Finds and executes the given command, filling in response response = None # This is where you start to implement more commands! if command.startswith(EXAMPLE_COMMAND): response = "Sure...write some more code then I can do that!" if 'weather' in command: response = weather.current_weather() #print(response) if 'joke' in command: response = jokes.get_joke() if 'quote' in command or 'motivation' in command: response = quotes.get_quote() #print(response) # Sends the response back to the channel slack_client.api_call("chat.postMessage", channel=channel, text=response or default_response)
def selection(what_i_said): find_truth = pre_selection(what_i_said, slct) if not find_truth: talking('How can I help you sir') menus.menu_choice() what_i_said = listening() what_i_said = what_i_said.replace('what\'s','what is') find_truth = pre_selection(what_i_said, slct) print find_truth while True: if (find_truth == [0, 1]) or (find_truth == [15]): games.play_hi_low() break elif find_truth == [2]: break elif (find_truth == [3, 4, 16, 17]) or (find_truth == [4, 9, 16, 17]) or (find_truth == [3, 4, 9, 16, 17]) \ or (find_truth == [3, 4]) or (find_truth == [4, 9]) or (find_truth == [3, 4, 9]): weather.current_weather() break elif (find_truth == [4, 5]) or (find_truth == [5]) or (find_truth == [4, 5, 16, 17]) or \ (find_truth == [4, 16, 17]): weather.forecast() break elif find_truth == [6, 7, 8]: games.RPSGame() break elif find_truth == [10]: games.tell_joke() break elif (find_truth == [11, 12]) or (find_truth == [11, 13]) or (find_truth == [11, 14]): todo_action.todo(find_truth) break elif (find_truth == [16, 17]) or (find_truth == [17, 18]) or (find_truth == [17, 19]) or \ (find_truth == [17, 20]) or (find_truth == [17, 21]) or (find_truth == [16, 22]) or \ (find_truth == [22, 18]) or (find_truth == [22, 19]) or (find_truth == [22, 20]) or \ (find_truth == [22, 21]): knowledge.wolfram_alpha(what_i_said) break else: decide(what_i_said) break
def set_weather(self): try: # Get the latitude and longitude of current IP and # then get the weather for said location. # Note that an api_key from openweathermap.org needs # to be provided. lat, lon = latlon('me') weather = current_weather(api_key='#', lat=lat, lon=lon) # Find the corresponding image to the weather description. weathericon = QtGui.QPixmap('images/' + weather['weather'][0]['icon'] + '.png') weathericon = weathericon.scaled(50, 50) # Find the corresponding arrow symbol to the wind direction. for di in self.direction: if di != '\u2191': if self.direction[di][0] <= weather['wind'][ 'deg'] <= self.direction[di][1]: direction = di else: if weather['wind']['deg'] > self.direction[di][0] or \ weather['wind']['deg'] < self.direction[di][1]: direction = di # Update the window with the new data. self.ui.weathericon.setPixmap(weathericon) self.ui.description.setText(weather['weather'][0]['description']) self.ui.temp.setText( str(round(weather['main']['temp'] - 273.15, 1)) + u'\u2103') self.ui.wind.setText(direction + ' ' + str(weather['wind']['speed']) + ' m/s') self.ui.humidity.setText( str(weather['main']['humidity']) + '% Humidity') except TypeError: # This will be raised if there is no internet connection. pass
def main(): # append the module name before the function name [else will get NameError ] weather.current_weather()
msg = str(event.object.message['text']) id_user = re.match(patterns['pattern_phone'], msg).group(3) if re.match(patterns['pattern_go'], msg): # ержана зовут бухать if number < 300: send_msg(id, 'выезжаю') elif number < 600: send_msg(id, 'без деда никуда не пойду') elif number < 900: send_msg(id, 'погнали') elif number > 900: send_msg(id, 'с дедом хоть на край света') elif re.match(patterns['pattern_weather'], msg) or msg == '!погода': # погода send_msg(id, current_weather()) elif re.match(patterns['pattern_days_left_to_zhd'], msg) or msg == '!зхд': # сколько дней до зхд zhd_left_days(id) elif re.match(patterns['pattern_how_many'], msg): # ищет вопрос сколько if number > 800: send_msg(id, 'дохуя') else: send_msg(id, round(number / 10)) elif msg == 'Ержан, работаешь?': # проверка бота работоспособность send_photo(id, 'photo-202528897_457239027') elif msg == 'Ержан, который час?': send_msg(id, 'время пива!')
def main(): weather.current_weather()
import dash_core_components as dcc import dash_html_components as html import datetime as dt import dash_table import dash_daq as daq import weather as w import dash_bootstrap_components as dbc import news as ns #import nfl from dash.dependencies import Input, Output import plotly.express as px import plotly.graph_objects as go import calendar #get temp values temp_fc = w.fore_cast() temp_c = w.current_weather() #get news news = ns.spiegel_news() #get nfl #nfl_s = nfl.nfl_stats() #get mapbox mapbox_access_token = "pk.eyJ1IjoibXgtbGNociIsImEiOiJjazJwMnBwOHoxMm1iM21uempkbWUxMmRvIn0._5SM_JZ4YO46nEg-F6-psA" mapbox_style = "mapbox://styles/mx-lchr/ck2p4pjk91b8f1cnytdrmy5gh/draft" app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP]) server = app.server colors = { #'background': '#0a0808', 'text': '#33c3f0' }