Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/texdarkstar/gw2-bot
This is an inheritable class for telnet robots, for playing godwars 2, written entirely in python. Cheers!
https://github.com/texdarkstar/gw2-bot
mud-client python-2
Last synced: about 1 month ago
JSON representation
This is an inheritable class for telnet robots, for playing godwars 2, written entirely in python. Cheers!
- Host: GitHub
- URL: https://github.com/texdarkstar/gw2-bot
- Owner: texdarkstar
- License: mit
- Created: 2017-12-03T06:58:06.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-24T18:45:19.000Z (almost 6 years ago)
- Last Synced: 2024-10-07T22:07:46.526Z (about 1 month ago)
- Topics: mud-client, python-2
- Language: Python
- Homepage: http://godwars2.org
- Size: 11.7 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Example usage:
```python
from time import sleep
from bot import Robotclass MyBot(Robot):
def init(self):
self.add_trigger(
regex=r"^You .*, '(.*)'$",
func=self.my_func,
name="my_func",
gag=True,
)def my_func(self, robot, string, matches):
print "Matched: %s" % stringdef do_something_once(self, robot, timer):
self.execute("say Hello world")
self.execute("say Hello again!")
def do_something_lots(self, robot, timer):
self.execute("say my timer ran %d time%s!" % (timer.runs, "s" if timer.runs > 1 else ""))
bot = MyBot("username", "password")bot.connect()
sleep(2)bot.add_timer(1, bot.do_something_once)
bot.add_timer(.1, bot.do_something_lots, max_runs=10)bot.execute("finger %s" % bot.username)
bot.loop()
```# Known quirks:
* The bot will not fire any triggers or write anything to the screen until you call its `loop()` function, which blocks the calling thread.# Tips on usage:
* If you want to run a single script but use multiple Robots, you will need a structure like so:
```python
from bot import Robot
import threadingdef start(bot):
bot.loop()def main():
threads = []
characters = {"GuyOne": "hispass", "GuyTwo": "hispass"}
for name in characters:
bot = Robot(name, characters[name], silent=True) # Likely will want to set silent=True, otherwise you're gonna get the
bot.connect() # mud output for each guy written to the same screen.
thread = threading.Thread(target=start, args=(bot,))
thread.start()
threads.append(thread)
main()```