summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dumbot.py93
-rw-r--r--icqRoombot.tac15
-rw-r--r--omegle/__init__.pycbin10666 -> 0 bytes
-rw-r--r--omegle/icq.pycbin6514 -> 0 bytes
-rw-r--r--omegle/icqBuddy.py12
-rw-r--r--omegle/icqChatroomBuddy.py13
-rw-r--r--omegle/icqRoombot.py14
-rw-r--r--unfoggedbot.py239
8 files changed, 33 insertions, 353 deletions
diff --git a/dumbot.py b/dumbot.py
deleted file mode 100644
index a017349..0000000
--- a/dumbot.py
+++ /dev/null
@@ -1,93 +0,0 @@
-#!/usr/bin/python
-
-# sucked from:
-# * http://twistedmatrix.com/pipermail/twisted-python/2004-May/007903.html
-# * http://redfoot.net/hypercode/modules/xmpp/client
-
-# Twisted Imports
-from twisted.words.protocols.jabber import client, jid
-from twisted.xish import domish, xmlstream
-from twisted.internet import reactor
-
-# System Imports
-import sys, getpass
-
-name = None
-server = None
-resource = None
-password = None
-me = None
-
-thexmlstream = None
-tryandregister = 1
-
-def initOnline(xmlstream):
- global factory
- print 'Initializing...'
- xmlstream.addObserver('/message', gotMessage)
- xmlstream.addObserver('/*', gotSomething)
-
-def authd(xmlstream):
- global thexmlstream
- thexmlstream = xmlstream
- print "we've authd!"
- print repr(xmlstream)
-
- #need to send presence so clients know we're
- #actually online
- presence = domish.Element(('jabber:client', 'presence'))
- presence.addElement('status').addContent('Online')
- xmlstream.send(presence)
-
- initOnline(xmlstream)
-
-def send(author, to, msg):
- global thexmlstream
- message = domish.Element(('jabber:client','message'))
- message["to"] = jid.JID(to).full()
- message["from"] = jid.JID(author).full()
- message["type"] = "chat"
- message.addElement("body", "jabber:client", msg)
-
- thexmlstream.send(message)
-
-def gotMessage(el):
- global me
- #print 'Got message: %s' % str(el.attributes)
- from_id = el["from"]
-
- body = "empty"
- for e in el.elements():
- if e.name == "body":
- body = unicode(e.__str__())
- break
-
- body = body.split(" ")
- body.reverse()
- body = " ".join(body)
-
- send(me, from_id, body)
-
-def gotSomething(el):
- print 'Got something: %s -> %s' % (el.name, str(el.attributes))
-
-def authfailedEvent(xmlstream):
- global reactor
- print 'Auth failed!'
- reactor.stop()
-
-if __name__ == '__main__':
- USER_HANDLE = raw_input("JID: ")
- PASSWORD = getpass.getpass()
- me = USER_HANDLE + "/TwistedWords"
- myJid = jid.JID(me)
- server = USER_HANDLE[USER_HANDLE.find('@')+1:]
-
- factory = client.basicClientFactory(myJid, PASSWORD)
-
- # Register authentication callbacks
- factory.addBootstrap(xmlstream.STREAM_AUTHD_EVENT, authd)
-
- # Go!
- reactor.connectTCP(server, 5222, factory)
- reactor.run()
diff --git a/icqRoombot.tac b/icqRoombot.tac
new file mode 100644
index 0000000..2f6fba1
--- /dev/null
+++ b/icqRoombot.tac
@@ -0,0 +1,15 @@
+#!/usr/bin/env twistd
+# vim: set ft=python sw=4 et syntax=python:
+
+from omegle.icq import ReconnectOscarFactory
+from omegle.icqRoombot import ICQRoombot
+from twisted.application import internet, service
+
+uin, password = ('370496181', 'megahal123')
+host, port = ('login.oscar.aol.com', 5190)
+
+factory = ReconnectOscarFactory(ICQRoombot, uin, password, icq=1)
+
+application = service.Application('icqRoombot')
+service = internet.TCPClient(host, port, factory)
+service.setServiceParent(application)
diff --git a/omegle/__init__.pyc b/omegle/__init__.pyc
deleted file mode 100644
index 7cf18a2..0000000
--- a/omegle/__init__.pyc
+++ /dev/null
Binary files differ
diff --git a/omegle/icq.pyc b/omegle/icq.pyc
deleted file mode 100644
index 9377150..0000000
--- a/omegle/icq.pyc
+++ /dev/null
Binary files differ
diff --git a/omegle/icqBuddy.py b/omegle/icqBuddy.py
index cd34cd4..c51419f 100644
--- a/omegle/icqBuddy.py
+++ b/omegle/icqBuddy.py
@@ -2,6 +2,7 @@
# -*- vim: encoding: utf-8 -*-
# Yves Fischer, xapek.org 2009
import sys
+import random
from twisted.words.protocols import oscar
from twisted.internet import reactor
@@ -13,6 +14,15 @@ from icq import ExtendedBOSConnection, ReconnectOscarFactory
ICQ_UIN = '446323989'
ICQ_PASSWORD = 'gagaga'
+def random_greetings():
+ gr = (
+ "Sup dawg, we heard u need some stranger in ur chatroom, so we put a Stranger in ur chatroom so u can chat with him while u chat with others (until you type %disconnect% anywhere)",
+ "Connected with Omegle, be retarted with strangers!",
+ "Omegle ... its like pedo-roulette",
+ "Under law 153:276:935 section 864, Omegle is required to inform you that the person you are currently chatting with owns the IP address of a registered sex offender. Please be careful when chatting with this person, and remember never to give out your personal information. The person you are chatting with cannot see this message.",
+ )
+ return "==== %s" % gr[random.randint(0,len(gr)-1)]
+
class OmegleICQChat(OmegleChat):
def __init__(self,icqconn,user):
self.user = user
@@ -45,7 +55,7 @@ class OmegleICQChat(OmegleChat):
def on_connect(self):
print "Omegle->%s: (connected)" % self.user
- self.send_icqconn( "== Sup dawg, we heard u need some stranger in ur chatroom, so we put a Stranger in ur chatroom so u can chat with him while u chat with others (until you type %disconnect% anywhere) ==" )
+ self.send_icqconn( random_greetings() )
def on_disconnect(self):
print "Omegle->%s: (disconnected)" % self.user
diff --git a/omegle/icqChatroomBuddy.py b/omegle/icqChatroomBuddy.py
index 63689f1..a235334 100644
--- a/omegle/icqChatroomBuddy.py
+++ b/omegle/icqChatroomBuddy.py
@@ -7,20 +7,21 @@ from twisted.words.protocols import oscar
from twisted.internet import reactor, protocol
from twisted.python import log
-from omegle.icqBuddy import OmegleICQ
+from omegle.icqBuddy import ICQBuddy
from icq import ReconnectOscarFactory
ICQ_UIN = '446323989'
ICQ_PASSWORD = 'gagaga'
ICQ_CHATROOM_UID = '370496181'
-class OmegleICQChatroomBuddy( OmegleICQ ):
- def gotBuddyList( self, buddylist ):
- OmegleICQ.gotBuddyList( self, buddylist )
- self.sendMessage(ICQ_CHATROOM_UID, "/join OMEGLE")
+class OmegleICQChatroomBuddy( ICQBuddy ):
+ def initDone( self ):
+ ICQBuddy.initDone(self)
+ reactor.callLater(5.0, self.sendMessage,ICQ_CHATROOM_UID, "/join OMEGLE")
+
def shutdown( self ):
self.sendMessage(ICQ_CHATROOM_UID, "/leave")
- OmegleICQ.shutdown(self)
+ ICQBuddy.shutdown(self)
if __name__ == '__main__':
diff --git a/omegle/icqRoombot.py b/omegle/icqRoombot.py
index cb6d730..3f463a5 100644
--- a/omegle/icqRoombot.py
+++ b/omegle/icqRoombot.py
@@ -4,7 +4,6 @@
import sys
from icq import ExtendedBOSConnection, ReconnectOscarFactory
from random import randint
-from twisted.python import log
from twisted.internet import reactor
class Member(object):
@@ -105,16 +104,3 @@ class ICQRoombot( ExtendedBOSConnection ):
self.sendAuthorizationResponse(user.name, True, '')
except Exception,e:
print "error: %s %s\n%s" % (user,multiparts,e)
-
-if __name__ == '__main__':
- uin = '370496181'
- password = 'megahal123'
- host, port = ('login.oscar.aol.com', 5190)
-
- import logging
- logging.basicConfig(level=logging.INFO)
- log.startLogging(sys.stdout)
-
- fac = ReconnectOscarFactory(ICQRoombot, uin, password, icq=1)
- reactor.connectTCP(host, port, fac)
- reactor.run()
diff --git a/unfoggedbot.py b/unfoggedbot.py
deleted file mode 100644
index 19362da..0000000
--- a/unfoggedbot.py
+++ /dev/null
@@ -1,239 +0,0 @@
-#! /usr/bin/python
-from twisted.words.protocols import oscar
-#import oscar
-## local copy taken from the py-aimt project.
-## some API differences, but it automagically does rate-limiting stuff.
-from twisted.internet import protocol, reactor
-from twisted.enterprise.adbapi import ConnectionPool
-from twisted.python import log
-import re, socket, sets, os
-#socket.setdefaulttimeout(60)
-
-
-DB = "ubotdb"
-RC = ".unfoggedbotrc"
-host, port = ('login.oscar.aol.com', 5190)
-
-## longer SQL.
-GETCOMMENT = "SELECT comment_id,link,thread_url,author,content,title FROM rss_items WHERE processed = 0 ORDER BY comment_id ASC LIMIT 1"
-GETPOST = "SELECT post_id, post_url, title FROM posts WHERE processed = 0 ORDER BY post_id ASC LIMIT 1"
-GETSUBSCRIBERS = "SELECT screen_name FROM subscriptions WHERE thread_url = ?"
-INSERTCOMMENTS = "INSERT OR IGNORE INTO rss_items (link, processed, thread_url, author, content, title) VALUES (?, ?, ?, ?, ?, ?)"
-INSERTPOSTS = "INSERT OR IGNORE INTO posts (post_url, title, processed) VALUES (?, ?, ?)"
-
-db = None
-
-permalink = re.compile("http://(www\.)?unfogged\.com/archives/week_...._.._..\.html#(\d+)")
-commentlink = re.compile("http://(www\.)?unfogged\.com/archives/comments_(\d+).html")
-
-ignorefirst = lambda f: lambda *a: f(*a[1:])
-mkmsg = lambda txt: [[txt.decode('utf-8').encode('utf-16-be'), 'unicode']]
-
-class UnfoggedBot(oscar.BOSConnection):
- def __init__(self, username, cookie):
- oscar.BOSConnection.__init__(self, username, cookie)
- self.offlines = sets.Set()
- self.lost = False
- db.runOperation("UPDATE posts SET processed = 1")\
- .addCallback(ignorefirst(db.runOperation),
- "UPDATE rss_items SET processed = 1")\
- .addCallback(ignorefirst(self.getnew))
-
- def connectionMade(self):
- oscar.BOSConnection.connectionMade(self)
- self.lost = False
-
- def connectionLost(self, reason):
- oscar.BOSConnection.connectionLost(self, reason)
- self.lost = True
-
- def initDone(self):
- log.msg("%s: in initDone" % self)
- self.requestSelfInfo()
- self.requestSSI().addCallback(self.gotBuddylist)
-
- def gotBuddylist(self, l):
- self.activateSSI()
- self.clientReady()
-
- def offlineBuddy(self, user):
- log.msg("User %s went offline" % user)
- self.offlines.add(user.name)
-
- def updateBuddy(self, user):
- msg = "User %s status change" % user.name
- if user.name in self.offlines:
- msg += "; removing from offlines set"
- self.offlines.remove(user.name)
- log.msg(msg)
-
-
- def _getnew(self, txn):
- if self.lost: return
- comment = txn.execute(GETCOMMENT).fetchall()
- if comment:
- turl = comment[0][2]
- crecipients = txn.execute(GETSUBSCRIBERS, (turl,)).fetchall()
- else: crecipients = [[[]]]
- post = txn.execute(GETPOST).fetchall()
- precipients = txn.execute("SELECT screen_name FROM subscriptions WHERE thread_url = ?", ("posts",)).fetchall()
- return (comment,
- post,
- [cr[0] for cr in crecipients],
- [pr[0] for pr in precipients],
- )
-
- def getnew(self):
- if self.lost: return
- reactor.callLater(3, self.getnew)
- db.runInteraction(self._getnew).addCallback(self.sendnew)
-
- def markread(self, txn, cid, pid):
- if self.lost: return
- if cid:
- txn.execute("UPDATE rss_items SET processed = 1 WHERE comment_id = ?", (cid,))
- if pid:
- txn.execute("UPDATE posts SET processed = 1 WHERE post_id = ?", (pid,))
-
- def sendnew(self, (comment, post, crecs, precs)):
- if comment:
- cid, link, turl, auth, cnt, title = comment[0]
- if len(cnt) >= 500:
- cnt = cnt[:497]+"..." #possibly cutting off tags
- msg = mkmsg('<b>%s</b> on <b><a href="%s">%s</a></b>: %s' %\
- (auth, link, title, cnt))
- crecs = [c for c in crecs if c not in self.offlines]
- if crecs: log.msg("Sending message to %s" % crecs)
- for crec in crecs:
- self.sendMessage(crec, msg)
- else: cid = None
- if post:
- pid, link, title = post[0]
- msg = mkmsg('New post!\n<a href="%s">%s</a>' % (link, title))
- precs = [p for p in precs if p not in self.offlines]
- if precs: log.msg("Sending new post alert to %s" % precs)
- for prec in precs:
- self.sendMessage(prec, msg)
- else: pid = None
- db.runInteraction(self.markread, cid, pid)
-
- def receiveMessage(self, user, multiparts, flags):
- try:
- msg = str(multiparts[0][0])
- except IndexError:
- log.msg("Index error on msg: \"%s\"?" % multiparts)
- return
- if self.trycommentsub(user, msg): return
- if re.search("(un)?subscribe posts", msg):
- db.runQuery("SELECT screen_name FROM subscriptions WHERE thread_url = ?", ("posts",)).addCallback(self.addremovepostsub, user.name)
-
- def trycommentsub(self, user, msg):
- for pat in (permalink, commentlink):
- m = pat.search(msg)
- if m:
- thread_id = re.sub('^0+', '', m.group(2))
- thread_url = "http://www.unfogged.com/archives/comments_%s.html" % thread_id
- break
- else:
- return
- return db.runInteraction(self._subinfo, thread_url).addCallback(self.addremovecommentsub, thread_url, user.name)
-
-
- def _subinfo(self, txn, turl):
- subscribers = txn.execute(GETSUBSCRIBERS, (turl,)).fetchall()
- try:
- threadname = txn.execute("SELECT title FROM posts WHERE post_url = ?", (turl,)).fetchall()[0][0]
- except IndexError:
- threadname = turl
- return ((str(s[0]) for s in subscribers), str(threadname))
-
- def addremovecommentsub(self, (subscribers, threadname), threadurl, uname):
- def sendfromcb(_, msg): self.sendMessage(uname, mkmsg(msg))
- if uname in subscribers:
- log.msg("unsubscribe %s from %s" % (uname, threadname))
- db.runOperation("DELETE FROM subscriptions WHERE screen_name = ? AND thread_url = ?", (uname, threadurl)).addCallback(sendfromcb, 'subscription to "%s" disabled.' % threadname)
- else:
- log.msg("subscribe %s to %s" % (uname, threadname))
- db.runOperation("INSERT INTO subscriptions (screen_name, thread_url) VALUES (?, ?)", (uname, threadurl)).addCallback(sendfromcb, 'subscription to "%s" enabled.' % threadname)
-
- def addremovepostsub(self, subscribers, uname):
- def sendfromcb(_, msg): self.sendMessage(uname, mkmsg(msg))
- if uname in (str(s[0]) for s in subscribers):
- log.msg("unsubscribe %s from posts" % uname)
- db.runOperation("DELETE FROM subscriptions WHERE screen_name = ? AND thread_url = ?", (uname, "posts")).addCallback(sendfromcb, "subscription to posts disabled.")
- else:
- log.msg("subscribe %s to posts" % uname)
- db.runOperation("INSERT INTO subscriptions (screen_name, thread_url) VALUES (?, ?)", (uname, "posts")).addCallback(sendfromcb, "subscription to posts enabled.")
-
-class ReconnectingOSCARFactory(protocol.ClientFactory):
- delay = 10.0
- protocol = UnfoggedBot
- def __init__(self, un, cookie):
- self.un = un
- self.cookie = cookie
- def buildProtocol(self, addr):
- p = self.protocol(self.un, self.cookie)
- p.factory = self
- return p
- def clientConnectionLost(self, connector, reason):
- reactor.callLater(self.delay, self._reconnect)
- def _reconnect(self):
- f = ReconnectingOSCARLoginFactory(sn, pass_)
- return reactor.connectTCP(host, port, f)
-
-class OA(oscar.OscarAuthenticator):
- BOSClass = UnfoggedBot
- connectfactory = ReconnectingOSCARFactory
- def connectToBOS(self, server, port):
- if not self.connectfactory:
- c = protocol.ClientCreator(reactor, self.BOSClass, self.username, self.cookie)
- return c.connectTCP(server, int(port))
- else:
- f = self.connectfactory(self.username, self.cookie)
- return reactor.connectTCP(server, int(port), f)
-
-class ReconnectingOSCARLoginFactory(protocol.ReconnectingClientFactory):
- protocol = OA
- def __init__(self, sn, pass_):
- self.sn = sn
- self.pass_ = pass_
- def buildProtocol(self, addr):
- p = self.protocol(self.sn, self.pass_, icq=0)
- p.factory = self
- return p
- ## only reconnect on *failures*
- def clientConnectionLost(self, con, reason):
- pass
-
-def getrss():
-##on the assumption that this can be done w/o using too much time,
-##I have taken this out of a separate thread.
- updaterss(comments, posts)
- reactor.callLater(15, getrss)
-
-def updaterss(comments, posts):
- def doinsertions(txn, commentdata, postdata):
- txn.executemany(INSERTCOMMENTS, commentdata)
- txn.executemany(INSERTPOSTS, postdata)
- commentdata, postdata = [], []
- for e in comments.entries:
- title = e.title.split("comments on ")[1][1:-1]
- thread_url = e.link.split('#')[0]
- commentdata.append((e.link, 0, thread_url, e.contributors[0]['name'],
- e.description, title))
- postdata = []
- for e in posts.entries:
- postdata.append((e.link, e.title, 0))
- db.runInteraction(doinsertions, commentdata, postdata)
-
-
-if __name__ == '__main__':
- sn,pass_="aa","bb"
- import sys
- sys.stderr = sys.stdout = open("ubot.log", "a+")
- log.startLogging(sys.stdout)
- f = ReconnectingOSCARLoginFactory(sn, pass_)
- reactor.connectTCP(host, port, f)
-
- getrss()
- reactor.run()