Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require irc >= 5.0 #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ FEATURES
INSTALL
-------

On Ubuntu/Debian you need `python-irclib` and `python-skype` as well as Skype itself to run the script.
On Ubuntu/Debian you need `python-irc` and `python-skype` as well as Skype itself to run the script.

For `python-skype` I used the version 1.0.31.0 provided at `ppa:skype-wrapper/ppa`. Although newer version is packaged even for Ubuntu 11.04, this package didn't work out of the box on Ubuntu 12.04. Using latest source version from https://github.com/awahlig/skype4py works fine on Ubuntu 14.04.

Expand Down
25 changes: 12 additions & 13 deletions skype2irc.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
import time, datetime
import string, textwrap

from ircbot import SingleServerIRCBot
from irclib import ServerNotConnectedError
from irc.bot import SingleServerIRCBot
from irc.client import ServerNotConnectedError
from threading import Timer

version = "0.3"
Expand Down Expand Up @@ -274,7 +274,7 @@ class MirrorBot(SingleServerIRCBot):
"""Create IRC bot class"""

def __init__(self):
SingleServerIRCBot.__init__(self, servers, nick, (botname + " " + topics).encode("UTF-8"), reconnect_interval)
SingleServerIRCBot.__init__(self, servers, nick, botname + " " + topics, reconnect_interval)

def start(self):
"""Override default start function to avoid starting/stalling the bot with no connection"""
Expand Down Expand Up @@ -311,12 +311,11 @@ def say(self, target, msg, do_say = True):
"""Send messages to channels/nicks"""
target = target.lower()
try:
lines = msg.encode("UTF-8").split("\n")
lines = msg.split("\n")
cur = 0
for line in lines:
for irc_msg in wrapper.wrap(line.strip("\r")):
print target, irc_msg
irc_msg += "\r\n"
if target not in lastsaid.keys():
lastsaid[target] = 0
while time.time()-lastsaid[target] < delay_btw_msgs:
Expand Down Expand Up @@ -353,9 +352,9 @@ def on_welcome(self, connection, event):

def on_pubmsg(self, connection, event):
"""React to channel messages"""
args = event.arguments()
source = event.source().split('!')[0]
target = event.target().lower()
args = event.arguments
source = event.source.split('!')[0]
target = event.target.lower()
cmds = args[0].split()
if cmds and cmds[0].rstrip(":,") == nick:
if len(cmds)==2:
Expand All @@ -377,9 +376,9 @@ def on_pubmsg(self, connection, event):

def handle_ctcp(self, connection, event):
"""Handle CTCP events for emoting"""
args = event.arguments()
source = event.source().split('!')[0]
target = event.target().lower()
args = event.arguments
source = event.source.split('!')[0]
target = event.target.lower()
if target in mirrors.keys():
if source in mutedl[target]:
return
Expand All @@ -391,8 +390,8 @@ def handle_ctcp(self, connection, event):

def on_privmsg(self, connection, event):
"""React to ON, OF(F), ST(ATUS), IN(FO) etc for switching gateway (from IRC side only)"""
source = event.source().split('!')[0]
raw = event.arguments()[0].decode('utf-8', 'ignore')
source = event.source.split('!')[0]
raw = event.arguments[0].decode('utf-8', 'ignore')
args = raw.split()
if not args:
return
Expand Down