Compare commits

...

11 Commits

Author SHA1 Message Date
jw 88c8827552
Merge pull request #61 from Cactii1/master
Add .smile trigger and fix mental trigger...
2021-07-11 11:47:49 -04:00
jw e54028b41e
Merge pull request #65 from scoobybejesus/patch-11
weather updates & weatherf
2021-07-11 11:47:40 -04:00
jw 111ea3e2e3
Merge pull request #64 from scoobybejesus/patch-10
Python3 update mostly. Removed sopel dups also.
2021-07-11 11:47:31 -04:00
jw 224b2c1604
Merge pull request #63 from scoobybejesus/patch-9
Make friendly for python3
2021-07-11 11:47:22 -04:00
jw 6bc3640c47
Merge pull request #62 from scoobybejesus/patch-8
Two ways to make python3 happy
2021-07-11 11:47:12 -04:00
scoobybejesus 59111f37d7
Fixed direction math. Whoops 2021-07-08 19:40:41 -04:00
scoobybejesus 213591e564
weather updates & weatherf
Add weatherf for farenheit and mph. For both, add wind direction. Break out vars to read easier.
2021-07-07 21:58:47 -04:00
scoobybejesus 322699ec02
Python3 update mostly. Removed sopel dups also.
Python3 syntax and removed sopel duplicates like unflip, shrug, lenny
2021-07-07 21:52:49 -04:00
scoobybejesus 316e8aa016
Make friendly for python3
python3 syntax
2021-07-07 21:39:27 -04:00
scoobybejesus aeb970f930
Two ways to make python3 happy
python3 syntax
2021-07-07 21:31:46 -04:00
Cactii1 1445a58039
Update trifling.py 2021-06-10 21:22:45 +02:00
3 changed files with 138 additions and 80 deletions

View File

@ -20,7 +20,7 @@ def fork(bot, trigger):
try: try:
r=requests.get(networkurl) r=requests.get(networkurl)
j=r.json() j=r.json()
except Exception,e: except Exception as e:
pass pass
try: try:
height=j["height"] height=j["height"]
@ -37,7 +37,7 @@ def network(bot, trigger):
try: try:
r=requests.get(networkurl) r=requests.get(networkurl)
j=r.json() j=r.json()
except Exception,e: except:
pass pass
try: try:
height=j["height"] height=j["height"]

View File

@ -243,11 +243,11 @@ def lending(bot, trigger):
currenttime=time.time() currenttime=time.time()
for i in j['offers']: for i in j['offers']:
amnt+=float(i['amount']) amnt+=float(i['amount'])
bot.say("Total amount of XMR available {0:,.2f}. Changed by {1:.2f} in the last {2:.2f} hours".format(amnt, amnt-prevamnt, (currenttime-prevtime)/3600))
global prevamnt global prevamnt
prevamnt=amnt prevamnt=amnt
global prevtime global prevtime
prevtime=currenttime prevtime=currenttime
bot.say("Total amount of XMR available {0:,.2f}. Changed by {1:.2f} in the last {2:.2f} hours".format(amnt, amnt-prevamnt, (currenttime-prevtime)/3600))
except: except:
bot.say("Something bad happened :o") bot.say("Something bad happened :o")
@ -276,7 +276,6 @@ def metal(bot, trigger):
@sopel.module.commands('polo', 'poloniex', 'marco', 'plol') @sopel.module.commands('polo', 'poloniex', 'marco', 'plol')
@sopel.module.interval(3600)
def polo(bot, trigger): def polo(bot, trigger):
if not trigger.group(2): if not trigger.group(2):
try: try:
@ -290,21 +289,21 @@ def polo(bot, trigger):
sign = '+' sign = '+'
else: else:
sign = '' sign = ''
face = '' face = u'\u0000'
if change > 0.10: if change > 0.10:
face = u'\u263d'.encode('utf8') face = u'\u263d'
if 0.10 >= change > 0.05: if 0.10 >= change > 0.05:
face = u'\u2661'.encode('utf8') face = u'\u2661'
if 0.05 >= change > 0.02: if 0.05 >= change > 0.02:
face = u'\u263a'.encode('utf8') face = u'\u263a'
if 0.02 >= change > -0.02: if 0.02 >= change > -0.02:
face = u'\u2694'.encode('utf8') face = u'\u2694'
if -0.02 >= change > -0.05: if -0.02 >= change > -0.05:
face = u'\u2639'.encode('utf8') face = u'\u2639'
if -0.05 >= change > -0.1: if -0.05 >= change > -0.1:
face = u'\u2620'.encode('utf8') face = u'\u2620'
if change < -0.1: if change < -0.1:
face = u'\u262d'.encode('utf8') face = u'\u262d'
bot.say("Poloniex at {0:.8f} BTC; {1}{2:.2f}% over 24 hours on {3:.3f} BTC volume {4}".format(last, sign, change*100, vol, face)) bot.say("Poloniex at {0:.8f} BTC; {1}{2:.2f}% over 24 hours on {3:.3f} BTC volume {4}".format(last, sign, change*100, vol, face))
except: except:
bot.say("Error retrieving data from Poloniex") bot.say("Error retrieving data from Poloniex")

View File

@ -6,7 +6,7 @@ import requests
import praw import praw
import client import client
from threading import Timer from threading import Timer
from HTMLParser import HTMLParser from html.parser import HTMLParser
@sopel.module.commands('4matter') @sopel.module.commands('4matter')
def fourmatter(bot, trigger): def fourmatter(bot, trigger):
@ -77,7 +77,7 @@ def bbl(bot, trigger):
@sopel.module.commands('bear') @sopel.module.commands('bear')
def bear(bot, trigger): def bear(bot, trigger):
bot.say(u'ʕ ·(エ)· ʔ'.encode('utf8')) bot.say(u'ʕ ·(エ)· ʔ')
@sopel.module.commands('billions') @sopel.module.commands('billions')
def billions(bot, trigger): def billions(bot, trigger):
@ -85,11 +85,11 @@ def billions(bot, trigger):
@sopel.module.commands('brothers') @sopel.module.commands('brothers')
def brothers(bot, trigger): def brothers(bot, trigger):
bot.say(u'http://www.trollaxor.com/2011/11/brief-history-of-ascii-penis.html'.encode('utf8')) bot.say(u'http://www.trollaxor.com/2011/11/brief-history-of-ascii-penis.html')
@sopel.module.commands('bp', 'bps', 'bulletproof', 'bulletproofs') @sopel.module.commands('bp', 'bps', 'bulletproof', 'bulletproofs')
def bulletproofs(bot, trigger): def bulletproofs(bot, trigger):
bot.say(u'https://www.youtube.com/watch?v=Kk8eJh4i8Lo'.encode('utf8')) bot.say(u'https://www.youtube.com/watch?v=Kk8eJh4i8Lo')
@sopel.module.commands('buyorsell') @sopel.module.commands('buyorsell')
def buyorsell(bot, trigger): def buyorsell(bot, trigger):
@ -186,7 +186,7 @@ def collect(bot, trigger):
value_of_items_collected_in_one_day = quantity * value_of_one_item value_of_items_collected_in_one_day = quantity * value_of_one_item
weekly_coins_to_buy = value_of_items_collected_in_one_day * 7 / coin_price weekly_coins_to_buy = value_of_items_collected_in_one_day * 7 / coin_price
bot.say('{0} price: ${1:,.2f}, and {2} price: ${3:,.3f}'.format(item.capitalize(), value_of_one_item, coin.capitalize(), coin_price)) bot.say('{0} price: ${1:,.2f}, and {2} price: ${3:,.2f}'.format(item.capitalize(), value_of_one_item, coin.capitalize(), coin_price))
bot.say('{0}: collect {1} per day to exchange for {2:,.5f} {3} each week!'.format(item.capitalize(), quantity, weekly_coins_to_buy, coin)) bot.say('{0}: collect {1} per day to exchange for {2:,.5f} {3} each week!'.format(item.capitalize(), quantity, weekly_coins_to_buy, coin))
@sopel.module.commands('covid', 'corona', 'conv') @sopel.module.commands('covid', 'corona', 'conv')
@ -247,7 +247,7 @@ def dash(bot, trigger):
@sopel.module.commands('dealwithit') @sopel.module.commands('dealwithit')
def dealwithit(bot, trigger): def dealwithit(bot, trigger):
bot.say(u'(•_•) ( •_•)>⌐■-■ (⌐■_■)'.encode('utf8')) bot.say(u'(•_•) ( •_•)>⌐■-■ (⌐■_■)')
@sopel.module.commands('Deathtobitcoin', 'Deathtobitcoin2') @sopel.module.commands('Deathtobitcoin', 'Deathtobitcoin2')
def deathtobitcoin2(bot, trigger): def deathtobitcoin2(bot, trigger):
@ -255,11 +255,11 @@ def deathtobitcoin2(bot, trigger):
@sopel.module.commands('diiorio') @sopel.module.commands('diiorio')
def diiorio(bot, trigger): def diiorio(bot, trigger):
bot.say(u'http://www.contravex.com/2016/06/29/from-the-scammer-files-anthony-di-iorio/'.encode('utf8')) bot.say(u'http://www.contravex.com/2016/06/29/from-the-scammer-files-anthony-di-iorio/')
@sopel.module.commands('disapprove') @sopel.module.commands('disapprove')
def disapprove(bot, trigger): def disapprove(bot, trigger):
bot.say(u'ಠ_ಠ'.encode('utf8')) bot.say(u'ಠ_ಠ')
@sopel.module.commands('ded') @sopel.module.commands('ded')
def ded(bot, trigger): def ded(bot, trigger):
@ -283,19 +283,19 @@ def encrypt(bot, trigger):
@sopel.module.commands('eth') @sopel.module.commands('eth')
def eth(bot, trigger): def eth(bot, trigger):
bot.say(u'The world computer 💻🌐'.encode('utf8')) bot.say(u'The world computer 💻🌐')
@sopel.module.commands('ferret', 'ferretinjapan') @sopel.module.commands('ferret', 'ferretinjapan')
def ferret(bot, trigger): def ferret(bot, trigger):
bot.say(u'♥‿♥ https://crypto314.com/wp-content/uploads/2017/09/monero-1505185532555-723x1024.png ♥‿♥'.encode('utf8')) bot.say(u'♥‿♥ https://crypto314.com/wp-content/uploads/2017/09/monero-1505185532555-723x1024.png ♥‿♥')
@sopel.module.commands('fib', 'fibonacci') @sopel.module.commands('fib', 'fibonacci')
def fib(bot, trigger): def fib(bot, trigger):
bot.say(u'Pardon me, do you have a moment to discuss our lord and savior ✞Cheesus Monero✞?'.encode('utf8')) bot.say(u'Pardon me, do you have a moment to discuss our lord and savior ✞Cheesus Monero✞?')
@sopel.module.commands('flip') @sopel.module.commands('flip')
def flip(bot, trigger): def flip(bot, trigger):
bot.say(u'(╯°□°)╯︵ ┻━┻'.encode('utf8')) bot.say(u'(╯°□°)╯︵ ┻━┻')
@sopel.module.commands('fuck') @sopel.module.commands('fuck')
def fuck(bot, trigger): def fuck(bot, trigger):
@ -381,7 +381,7 @@ def jaxx(bot, trigger):
bot.say(u'This command will be implemented soon. Honest. Especially if the devs can provide some unpaid assistance. Soon™...') bot.say(u'This command will be implemented soon. Honest. Especially if the devs can provide some unpaid assistance. Soon™...')
@sopel.module.commands('jimbell') @sopel.module.commands('jimbell')
def jaxx(bot, trigger): def jimbell(bot, trigger):
if not trigger.group(2): if not trigger.group(2):
bot.say(u'https://en.wikipedia.org/wiki/Jim_Bell') bot.say(u'https://en.wikipedia.org/wiki/Jim_Bell')
else: else:
@ -409,19 +409,15 @@ def kramer(bot, trigger):
@sopel.module.commands('lambo') @sopel.module.commands('lambo')
def lambo(bot, trigger): def lambo(bot, trigger):
bot.say(u'Our mission is to give you a taste of the lambo dream 🏎 '.encode('utf8')) bot.say(u'Our mission is to give you a taste of the lambo dream 🏎 ')
@sopel.module.commands('lenny')
def lenny(bot, trigger):
bot.say(u'( ͡° ͜ʖ ͡°)'.encode('utf8'))
@sopel.module.commands('lietome') @sopel.module.commands('lietome')
def lietome(bot, trigger): def lietome(bot, trigger):
bot.say(u'https://www.youtube.com/watch?v=R5AsQbLHWbw'.encode('utf8')) bot.say(u'https://www.youtube.com/watch?v=R5AsQbLHWbw')
@sopel.module.commands('livermore') @sopel.module.commands('livermore')
def livermore(bot, trigger): def livermore(bot, trigger):
bot.say(u'https://en.wikipedia.org/wiki/Reminiscences_of_a_Stock_Operator'.encode('utf8')) bot.say(u'https://en.wikipedia.org/wiki/Reminiscences_of_a_Stock_Operator')
@sopel.module.commands('loki') @sopel.module.commands('loki')
def loki(bot, trigger): def loki(bot, trigger):
@ -429,11 +425,11 @@ def loki(bot, trigger):
@sopel.module.commands('luigi') @sopel.module.commands('luigi')
def luigi(bot, trigger): def luigi(bot, trigger):
bot.say(u'🍄 luigi is doing. mario is not doing luigi is doing 🍄'.encode('utf8')) bot.say(u'🍄 luigi is doing. mario is not doing luigi is doing 🍄')
@sopel.module.commands('ltc', 'chikun') @sopel.module.commands('ltc', 'chikun')
def ltc(bot, trigger): def ltc(bot, trigger):
bot.say(u'🐔🐔🐔 https://cdn.meme.am/cache/instances/folder100/48222100.jpg 🐔🐔🐔'.encode('utf8')) bot.say(u'🐔🐔🐔 https://cdn.meme.am/cache/instances/folder100/48222100.jpg 🐔🐔🐔')
@sopel.module.commands('major') @sopel.module.commands('major')
def major(bot, trigger): def major(bot, trigger):
@ -445,43 +441,43 @@ def masternode(bot, trigger):
@sopel.module.commands('monerov', 'v') @sopel.module.commands('monerov', 'v')
def monerov(bot, trigger): def monerov(bot, trigger):
bot.say(u"🔒🔒🔒 MoneroV is more secured than others. That's why it is better invest on moneroV. 💰💰💰".encode('utf8')) bot.say(u"🔒🔒🔒 MoneroV is more secured than others. That's why it is better invest on moneroV. 💰💰💰")
@sopel.module.commands('moon') @sopel.module.commands('moon')
def moon(bot, trigger): def moon(bot, trigger):
bot.say(u'┗(°0°)┛'.encode('utf8')) bot.say(u'┗(°0°)┛')
@sopel.module.commands('multisig') @sopel.module.commands('multisig')
def multisig(bot, trigger): def multisig(bot, trigger):
bot.say(u'𝓼𝓲𝓰𝓷𝓪𝓽𝓾𝓻𝓮 𝓼𝓲𝓰𝓷𝓪𝓽𝓾𝓻𝓮'.encode('utf8')) bot.say(u'𝓼𝓲𝓰𝓷𝓪𝓽𝓾𝓻𝓮 𝓼𝓲𝓰𝓷𝓪𝓽𝓾𝓻𝓮')
@sopel.module.commands('myriad', 'myr', 'myriadcoin') @sopel.module.commands('myriad', 'myr', 'myriadcoin')
def myriad(bot, trigger): def myriad(bot, trigger):
bot.say(u'Myriad - A coin for everyone 🖐'.encode('utf8')) bot.say(u'Myriad - A coin for everyone 🖐')
@sopel.module.commands('needmoney', 'needmoney90', 'nm90') @sopel.module.commands('needmoney', 'needmoney90', 'nm90')
def needmoney(bot, trigger): def needmoney(bot, trigger):
bot.say(u'cash rules everything around me C.R.E.A.M get the money 💵 💵 bill yall'.encode('utf8')) bot.say(u'cash rules everything around me C.R.E.A.M get the money 💵 💵 bill yall')
@sopel.module.commands('nioc') @sopel.module.commands('nioc')
def nioc(bot, trigger): def nioc(bot, trigger):
bot.say(u'https://ifunny.co/fun/laeIohx56'.encode('utf8')) bot.say(u'https://ifunny.co/fun/laeIohx56')
@sopel.module.commands('nobody') @sopel.module.commands('nobody')
def nobody(bot, trigger): def nobody(bot, trigger):
bot.say('https://www.youtube.com/watch?v=YA631bMT9g8') bot.say('https://www.youtube.com/watch?v=YA631bMT9g8')
@sopel.module.commands('nomnomnom') @sopel.module.commands('nomnomnom', 'nomnom')
def nomnomnom(bot, trigger): def nomnomnom(bot, trigger):
bot.say(u'ᗧ•••ᗣ'.encode('utf8')) bot.say(u'ᗧ•••ᗣ')
@sopel.module.commands('noom') @sopel.module.commands('noom')
def noom(bot, trigger): def noom(bot, trigger):
bot.say(u'┏(.0.)┓'.encode('utf8')) bot.say(u'┏(.0.)┓')
@sopel.module.commands('notbad', 'dorian') @sopel.module.commands('notbad', 'dorian')
def notbad(bot, trigger): def notbad(bot, trigger):
bot.say(u'(´ー`) http://hackingdistributed.com/images/2014-01-01-bitcoin/dorian1.jpg (´ー`)'.encode('utf8')) bot.say(u'(´ー`) http://hackingdistributed.com/images/2014-01-01-bitcoin/dorian1.jpg (´ー`)')
@sopel.module.commands('obama') @sopel.module.commands('obama')
def obama(bot, trigger): def obama(bot, trigger):
@ -557,7 +553,7 @@ def projecting(bot, trigger):
@sopel.module.commands('purge') @sopel.module.commands('purge')
def purge(bot, trigger): def purge(bot, trigger):
bot.say(u'♔♔♔ Bow to the king https://preview.redd.it/fr8q7x9utnzy.png?width=612&auto=webp&s=8bf7aa7674d2dc3157b776ae07771144833cd879 ♔♔♔'.encode('utf8')) bot.say(u'♔♔♔ Bow to the king https://preview.redd.it/fr8q7x9utnzy.png?width=612&auto=webp&s=8bf7aa7674d2dc3157b776ae07771144833cd879 ♔♔♔')
@sopel.module.commands('rarepepe', 'rare') @sopel.module.commands('rarepepe', 'rare')
def rarepepe(bot, trigger): def rarepepe(bot, trigger):
@ -579,11 +575,11 @@ def rarepepe(bot, trigger):
@sopel.module.commands('rip') @sopel.module.commands('rip')
def rip(bot, trigger): def rip(bot, trigger):
bot.say(u'(X_X) ☜ (◉▂◉ ) we hardly knew ye'.encode('utf8')) bot.say(u'(X_X) ☜ (◉▂◉ ) we hardly knew ye')
@sopel.module.commands('risto', 'rpietila') @sopel.module.commands('risto', 'rpietila')
def risto(bot, trigger): def risto(bot, trigger):
bot.say(u'Zionists own the media, including Hollywood. It is nothing extraordinary for them to use it to further their goals. Just see what they are propagating every day in every media outlet. And the compulsory disclaimer: Zionist != Jew. Zionists in my understanding are typically mostly not even ethnic Jews, and the supermajority of Jews certainly are not Zionists. Zionism is a purely political supremacy movement.'.encode('utf8')) bot.say(u'Zionists own the media, including Hollywood. It is nothing extraordinary for them to use it to further their goals. Just see what they are propagating every day in every media outlet. And the compulsory disclaimer: Zionist != Jew. Zionists in my understanding are typically mostly not even ethnic Jews, and the supermajority of Jews certainly are not Zionists. Zionism is a purely political supremacy movement.')
@sopel.module.commands('romerito', 'romero') @sopel.module.commands('romerito', 'romero')
def romerito(bot, trigger): def romerito(bot, trigger):
@ -631,19 +627,15 @@ def scam(bot, trigger):
@sopel.module.commands('soon') @sopel.module.commands('soon')
def soon(bot, trigger): def soon(bot, trigger):
bot.say(u'Two weeks™'.encode('utf8')) bot.say(u'Two weeks™')
@sopel.module.commands('shillo', 'cid') @sopel.module.commands('shillo', 'cid')
def shillo(bot, trigger): def shillo(bot, trigger):
bot.say(u'☠☠☠ Crypto is ded https://i.kym-cdn.com/photos/images/original/001/321/553/f03.jpg ☠☠☠ '.encode('utf8')) bot.say(u'☠☠☠ Crypto is ded https://i.kym-cdn.com/photos/images/original/001/321/553/f03.jpg ☠☠☠ ')
@sopel.module.commands('shrug')
def shrug(bot, trigger):
bot.say(u'¯\_(ツ)_/¯'.encode('utf8'))
@sopel.module.commands('softich') @sopel.module.commands('softich')
def softich(bot, trigger): def softich(bot, trigger):
bot.say(u'🐻🐻🐻 https://imgflip.com/i/1ve397 🐻🐻🐻'.encode('utf8')) bot.say(u'🐻🐻🐻 https://imgflip.com/i/1ve397 🐻🐻🐻')
@sopel.module.commands('summon') @sopel.module.commands('summon')
def summon(bot, trigger): def summon(bot, trigger):
@ -729,10 +721,6 @@ def trump(bot, trigger):
def trumbleweed(bot, trigger): def trumbleweed(bot, trigger):
bot.say("https://rootco.de/2016-03-28-why-use-tumbleweed/") bot.say("https://rootco.de/2016-03-28-why-use-tumbleweed/")
@sopel.module.commands('unflip')
def unflip(bot, trigger):
bot.say(u'┬─┬ノ( º _ ºノ)'.encode('utf8'))
urmomoptions = [ urmomoptions = [
"ur mom is so stupid she bought all the dash", "ur mom is so stupid she bought all the dash",
"ur momma got a peg leg with a kickstand", "ur momma got a peg leg with a kickstand",
@ -756,7 +744,7 @@ def urmom(bot, trigger):
@sopel.module.commands('verge', 'xvg', 'wraith') @sopel.module.commands('verge', 'xvg', 'wraith')
def verge(bot, trigger): def verge(bot, trigger):
bot.say(u"👻🐕 Don't wraith my dark doge bro! 👻🐕".encode('utf8')) bot.say(u"👻🐕 Don't wraith my dark doge bro! 👻🐕")
vitalikoptions = [ vitalikoptions = [
"https://pbs.twimg.com/media/CrWjczJXgAExF2S.jpg", "https://pbs.twimg.com/media/CrWjczJXgAExF2S.jpg",
@ -802,7 +790,7 @@ def test(bot, trigger):
@sopel.module.rule('monerobux o\/') @sopel.module.rule('monerobux o\/')
def wave(bot, trigger): def wave(bot, trigger):
#bot.reply(u'^ (•_•) ^'.encode('utf8')) #bot.reply(u'^ (•_•) ^')
bot.reply('hello') bot.reply('hello')
#@sopel.module.rule('[Tt]rump') #@sopel.module.rule('[Tt]rump')
#def politics(bot, trigger): #def politics(bot, trigger):
@ -900,12 +888,79 @@ def weather(bot, trigger):
location = "zip="+location location = "zip="+location
else: else:
location = "q="+location.replace(' ', '%20') location = "q="+location.replace(' ', '%20')
r = requests.get('https://api.openweathermap.org/data/2.5/weather?{}&appid={}'.format(location, wk)) r = requests.get('https://api.openweathermap.org/data/2.5/weather?{}&appid={}'.format(location, wk))
j = r.json() j = r.json()
location = j['name']+', '+j['sys']['country']
humidity = j['main']['humidity']
wind_speed_m_s = j['wind']['speed']
wind_deg = j['wind']['deg']
description = j['weather'][0]['description']
temp_in_c = float(j['main']['temp'])-273
low_in_c = float(j['main']['temp_min'])-273
high_in_c = float(j['main']['temp_max'])-273
temp = temp_in_c
low = low_in_c
high = high_in_c
def calculate_bearing(d):
dirs = ['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW']
ix = int(round(d / (360. / len(dirs))))
return dirs[(ix) % len(dirs)]
direction = calculate_bearing(wind_deg)
try: try:
bot.say("In {} it is {:.2f} C with a low of {:.2f} and high of {:.2f} C, humidity is {}%, winds of {} m/s at an angle of {} deg with {}.".format(j['name']+', '+j['sys']['country'], float(j['main']['temp'])-273, float(j['main']['temp_min'])-273, float(j['main']['temp_max'])-273, j['main']['humidity'], j['wind']['speed'], j['wind']['deg'], j['weather'][0]['description'])) bot.say("In {} it is {:.1f} C with a low of {:.1f} and high of {:.1f} C, humidity is {}%, winds of {} m/s from the {} with {}.".format(location, temp, low, high, humidity, wind_speed_m_s, direction, description))
except: except:
bot.say("In {} it is {:.2f} C with a low of {:.2f} and high of {:.2f} C, humidity is {}%, winds of {} m/s with {}.".format(j['name']+', '+j['sys']['country'], float(j['main']['temp'])-273, float(j['main']['temp_min'])-273, float(j['main']['temp_max'])-273, j['main']['humidity'], j['wind']['speed'], j['weather'][0]['description'])) bot.say("In {} it is {:.2f} C with a low of {:.2f} and high of {:.2f} C, humidity is {}%, winds of {} m/s with {}.".format(location, temp, low, high, humidity, wind_speed_m_s, description))
except:
bot.say("The earth is on fire 🌎🔥")
@sopel.module.commands('weatherf')
def weatherf(bot, trigger):
wk = client.weather_key
try:
if not trigger.group(2):
location = q="san%20francisco"
elif trigger.group(2) == 'nioc':
location = 'new york city'
else:
location = trigger.group(2)
if location.isdigit():
location = "zip="+location
else:
location = "q="+location.replace(' ', '%20')
r = requests.get('https://api.openweathermap.org/data/2.5/weather?{}&appid={}'.format(location, wk))
j = r.json()
location = j['name']+', '+j['sys']['country']
humidity = j['main']['humidity']
wind_speed_m_s = j['wind']['speed']
wind_deg = j['wind']['deg']
description = j['weather'][0]['description']
temp_in_c = float(j['main']['temp'])-273
low_in_c = float(j['main']['temp_min'])-273
high_in_c = float(j['main']['temp_max'])-273
temp = (temp_in_c * 9 / 5 ) + 32
low = (low_in_c * 9 / 5 ) + 32
high = (high_in_c * 9 / 5 ) + 32
wind_speed_mph = float(wind_speed_m_s) * 2.236936
def calculate_bearing(d):
dirs = ['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW']
ix = int(round(d / (360. / len(dirs))))
return dirs[(ix) % len(dirs)]
direction = calculate_bearing(wind_deg)
try:
bot.say("In {} it is {:.1f} F with a low of {:.1f} and high of {:.1f} F, humidity is {}%, winds of {:.1f} mph from the {} with {}.".format(location, temp, low, high, humidity, wind_speed_mph, direction, description))
except:
bot.say("In {} it is {:.1f} F with a low of {:.1f} and high of {:.1f} F, humidity is {}%, winds of {:.1f} mph with {}.".format(location, temp, low, high, humidity, wind_speed_mph, description))
except: except:
bot.say("The earth is on fire 🌎🔥") bot.say("The earth is on fire 🌎🔥")
@ -925,5 +980,9 @@ def mental(bot, trigger):
bot.say('Ahhhhhhhh!!!!') bot.say('Ahhhhhhhh!!!!')
@sopel.module.commands('biden') @sopel.module.commands('biden')
def mental(bot, trigger): def biden(bot, trigger):
bot.say('Come on man...') bot.say('Come on man...')
@sopel.module.commands('smile')
def smile(bot, trigger):
bot.say('https://archive.is/uqHxO')