Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kote committed Aug 2, 2019
1 parent dc4c273 commit 15cd690
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 24 deletions.
17 changes: 17 additions & 0 deletions howto.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
virtualenv venv1 --python=python3




pip install ipwhois
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.


pip install ssl
pip install ssl


sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

pip install ipwhois
pip install ipwhois
57 changes: 33 additions & 24 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,12 @@ def link_title(n):
list_bot_not_work = settings.settings('list_bot_not_work')

while True:
try:
data = irc.recv(2048).decode("UTF-8")
except:
continue
#try:
data = irc.recv(2048).decode("UTF-8")
print("rx:"+data)
#except:
# print("rx_except")
# continue
if data.find('PING') != -1:
send('PONG '+data.split(" ")[1]+'\r\n')

Expand All @@ -149,7 +151,7 @@ def link_title(n):
name = data.split('!',1)[0][1:]
message = data.split('PRIVMSG',1)[1].split(':',1)[1]
try:
ip_user=data.split('@',1)[1].split(' ',1)[0]
ip_user=None#"data.split('@',1)[1].split(' ',1)[0]
except:
print('error getting ip_user')

Expand Down Expand Up @@ -230,7 +232,7 @@ def link_title(n):
mes_per_bot = message.split('!ะฝะฐะฟะธัˆะธ ',1)[1]
send(mes_per_bot)

#---------Whois servis--------------------------
#---------Whois service--------------------------

if enableother1:
if 'PRIVMSG '+channel+' :!ะณะดะต ะฐะนะฟะธ' in data\
Expand Down Expand Up @@ -262,7 +264,7 @@ def link_title(n):
send('PRIVMSG '+where_message_whois+' :'+whois_final_reply)

except:
print('get Value Error in whois servis!')
print('get Value Error in whois service!')
send('PRIVMSG '+where_message_whois+' :ะžัˆะธะฑะบะฐ! ะ’ะฒะพะดะธั‚ะต ั‚ะพะปัŒะบะพ IP ะฐะดั€ะตั \
ะธะท ั†ะธั„ั€, ั€ะฐะทะดะตะปะตะฝะฝั‹ั… ั‚ะพั‡ะบะฐะผะธ!\r\n')

Expand Down Expand Up @@ -378,11 +380,17 @@ def link_title(n):
send('PRIVMSG '+channel+' : ะžะฟั€ะพั ะพะบะพะฝั‡ะตะฝ!\r\n')
send(voting_results)

if 'PRIVMSG '+channel+' :!ะบัƒั€ั' in data or 'PRIVMSG '+botName+' :!ะบัƒั€ั' in data:
if 'PRIVMSG '+channel+' :!ะบัƒั€ั' in data:
where_mes_exc = channel
if 'PRIVMSG '+botName+' :!ะบัƒั€ั' in data:
where_mes_exc = name
#:[email protected] PRIVMSG #ru :!ะบัƒั€ั
dataTokensDelimitedByWhitespace = data.split(" ")
#dataTokensDelimitedByWhitespace[0] :[email protected]
#dataTokensDelimitedByWhitespace[1] PRIVMSG
#dataTokensDelimitedByWhitespace[2] #ru
#dataTokensDelimitedByWhitespace[3] :!ะบัƒั€ั
if (len(dataTokensDelimitedByWhitespace) > 3) and ('!ะบัƒั€ั' in dataTokensDelimitedByWhitespace[3]):
print('!ะบัƒั€ั')
communicationsLineName = dataTokensDelimitedByWhitespace[2]
where_mes_exc = communicationsLineName
print('ะบัƒั€ั ะบัƒะดะฐ ัะปะฐั‚ัŒ ะฑัƒะดะตะผ:', where_mes_exc)

try:
#This example uses Python 2.7 and the python-request library.
Expand All @@ -405,24 +413,25 @@ def link_title(n):
session.headers.update(headers)

try:
print('!ะบัƒั€ั session.get url='+url)
response = session.get(url, params=parameters)
cmc = json.loads(response.text)
print(cmc)
print("cmc:", cmc)
btc_usd = cmc["data"]["BTC"]["quote"]["USD"]["price"]
eth_usd = cmc["data"]["ETH"]["quote"]["USD"]["price"]
btc_usd_str = str(btc_usd)
eth_usd_str = str(eth_usd)

send_res_exc = '\x033ะšัƒั€ั CoinMarketCap: \x02BTC/USD:\x02 '+btc_usd_str+' \x02ETH/USD:\x02 '+eth_usd_str+'\r\n'
print("send_res_exc:", send_res_exc)
print("where_mes_exc:", where_mes_exc)
send('PRIVMSG %s :%s\r\n'%(where_mes_exc,send_res_exc))
except (ConnectionError, Timeout, TooManyRedirects) as e:
print(e)
except:
print('ะ˜ัะบะปัŽั‡ะตะฝะธะต api cmc: ?')
btc_usd = cmc["data"]["BTC"]["quote"]["USD"]["price"]
eth_usd = cmc["data"]["ETH"]["quote"]["USD"]["price"]
except (ConnectionError, Timeout, TooManyRedirects) as e:
print(e)


btc_usd_str = str(btc_usd)
eth_usd_str = str(eth_usd)

send_res_exc = '\x033ะšัƒั€ั CoinMarketCap: \x02BTC/USD:\x02 '+btc_usd_str+' \x02ETH/USD:\x02 '+eth_usd_str+'\r\n'

send('PRIVMSG %s :%s\r\n'%(where_mes_exc,send_res_exc))

#------------Printing---------------

print(data)
1 change: 1 addition & 0 deletions startbotdaemon.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit 15cd690

Please sign in to comment.