forked from kaibruneji/MyIrcBot
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
kote
committed
Aug 2, 2019
1 parent
dc4c273
commit 15cd690
Showing
3 changed files
with
51 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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') | ||
|
||
|
@@ -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') | ||
|
||
|
@@ -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\ | ||
|
@@ -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') | ||
|
||
|
@@ -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. | ||
|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|